cphalcon icon indicating copy to clipboard operation
cphalcon copied to clipboard

[NFR] Form field position

Open mitris opened this issue 13 years ago • 5 comments

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

mitris avatar Jun 18 '13 08:06 mitris

it can be useful +1

iforp avatar Jun 18 '13 15:06 iforp

This seems to be a duplicate of #433

ghost avatar Jun 19 '13 22:06 ghost

This is stuff which belongs in individual classes, not a core framework.

philippgerard avatar Jun 21 '13 14:06 philippgerard

@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

iforp avatar Jun 21 '13 19:06 iforp

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');

dreamsxin avatar Oct 16 '13 09:10 dreamsxin