📜 ⬆️ ⬇️

Kohana-form: beta release. Changes and innovations

Hello. Finally, the day came when the module acquired the outline I was aiming for. In this regard, a beta release has been released, and I would like to tell you what's new in the kohana-form functionality.

First article - habrahabr.ru/post/216187


')
The new types of fields were joined by new ones, which were so lacking in the first version.

These are fields with type:


I think from the name of the File field, and so it is clear why it is intended, so I will not chew.
The Choice and Multichoice fields by default generate single and multiple selects. It is fairly simple to initialize.

"fields" => array( "select" => Field::factory("Choice", array( "choices" => array(1, 2, 3) )), "select" => Field::factory("MultiChoice", array( "choices" => array(1, 2, 3) )), ), 


But the most important innovation is Relation fields.
These are fields with type:


Initializing is as easy as Choice type fields, but they need to be initialized in a separate section 2m_fields.

  "fields" => array(), "2m_fields" => array( "owners" => Field::factory("One2Many", array( "model" => ORM::factory("Owner") )) "owners" => Field::factory("Many2Many", array( "model" => ORM::factory("Owner") )) ), 


Generated selects with loaded links. However, I do not recommend using these fields anywhere except in the admin area, and in the admin area you should use it wisely. Most often, you can get by with the BelongsTo field, which is also represented in the module and initialized this way:

  "fields" => array( "image" => Field::factory("Image"), "owner" => Field::factory("BelongsTo", array( "model" => ORM::factory("Owner") )), "body" => Field::factory("Text")->widget("CKEditor") ), 


Plus, from the example above, you can see that a new widget has appeared, replacing the standard textarea.
Also, there were several types of fields that are not very different in functionality from the existing ones, but are needed to generate the form from the ORM model, and now there is no need to focus on them.
That's all, there are not so many changes, but they are quite voluminous and finally made the kohana-form the way I saw it when I just sat at the keyboard.

However, it’s too early to relax, the project is only in the beta testing stage, and just like last time I ask the community for help with testing, development, writing documentation, so that together we can make the best module of forms available.

Thanks for attention.

Source: https://habr.com/ru/post/222649/


All Articles