[NFR] Form field position
If form reusable and stored in some class
class MyForm {
public function __construct() {
$form = new Form();
$form->add(new Text('name'));
return $form;
}
}
Suppose that I want dynamically add new fields to form, but i want change theirs positions, so it would be reasonable add positional feature.
use Phalcon\Forms\Form,
Phalcon\Forms\Element\Text;
$myForm = new MyForm();
$myForm->add(new Text('year'), Form::POSITION_AFTER, 'name'); // const, which says insert new field after field named 'name'
$myForm->add(new Text('year'), Form::POSITION_BEFORE, 'name'); // const, which says insert new field before field named 'name'
$myForm->add(new Text('year'), Form::POSITION_APPEND); // const, which says insert new field to bottom of form
$myForm->add(new Text('year'), Form::POSITION_PREPEND); // const, which says insert new field to top of form
it can be useful +1
This seems to be a duplicate of #433
This is stuff which belongs in individual classes, not a core framework.
@philippgerard nope, think it should be the core functionallity https://github.com/phalcon/cphalcon/issues/433 is right - it's everyday usage
@phalcon this issues is similar, but #433 is more complex May be it possible to solve this issues with both solutions: set numeric ordering and/or set after/before/append/prepend ordering
For example:
$form = new \Phalcon\Forms\Form();
$form->add(new \Phalcon\Forms\Element\Text('name'));
$form->addAt(new \Phalcon\Forms\Element\Text('before'), 'name', true);
$form->addAt(new \Phalcon\Forms\Element\Text('after'), 'name');