public function initialize($entity = null, $options = null) { $country = new Select('countryid', Country::find(), array('using' => array('id', 'country'), 'useEmpty' => TRUE, 'emptyText' => $this->di->get('translate')->_('Seleccione un País'))); $country->setLabel('País'); $this->add($country); if (isset($entity)) { if ($entity->getCountryid()) { $state = new Select('stateid', State::find(array("columns" => array("id,state"), "conditions" => "countryid =:countryid:", "bind" => array("countryid" => $entity->countryid))), array("useEmpty" => true, "emptyText" => $this->di->get('translate')->_('Seleccione un Estado'), 'using' => array('id', 'state'))); $state->setLabel('Estado'); $this->add($state); $city = new Select('cityid', City::find(array("columns" => array("id,city"), "conditions" => "countryid =:countryid: AND stateid =:stateid: ", "bind" => array("countryid" => $entity->countryid, "stateid" => $entity->stateid))), array("useEmpty" => true, "emptyText" => $this->di->get('translate')->_('Seleccione una ciudad'), 'using' => array('id', 'city'))); $city->setLabel('Ciudad'); $this->add($city); $township = new Select('townshipid', Township::find(array("columns" => array("id,township"), "conditions" => "cityid =:cityid:", "bind" => array("cityid" => $entity->cityid))), array("useEmpty" => true, "emptyText" => $this->di->get('translate')->_('Seleccione un Sector'), 'using' => array('id', 'township'))); $township->setLabel('Sector'); $this->add($township); $neighborhood = new Select('neighborhoodid', Neighborhood::find(array("columns" => array("id,neighborhood"), "conditions" => "cityid =:cityid:", "bind" => array("cityid" => $entity->cityid))), array("useEmpty" => true, "emptyText" => $this->di->get('translate')->_('Seleccione un Barrio'), 'using' => array('id', 'neighborhood'))); $neighborhood->setLabel('Barrio'); $this->add($neighborhood); } else { $this->set_empty_values(); } } else { $this->set_empty_values(); } $address = new Textarea('address', array("maxlength" => "400")); $address->setLabel('Dirección'); $this->add($address); $description = new Textarea('description', array("maxlength" => "100")); $description->setLabel('Descripción'); $this->add($description); }
public function initialize($entity = null, $options = null) { $created = new Date('created'); $created->setLabel('Дата'); $this->add($created); $sum = new Numeric('sum'); $sum->setLabel('Сумма'); $this->add($sum); $categoryID = new Hidden('categoryID'); $this->add($categoryID); $text = new Textarea('text'); $text->setLabel('Описание'); $this->add($text); }
/** * Form configuration */ public function initialize($entity = null, $options = null) { $t = $this->getDI()->get('translate'); // In edition the id is hidden if (isset($options['edit']) && $options['edit']) { $id = new Hidden('id'); } else { $id = new Text('id'); } $id->setLabel($t->gettext('Id')); $this->add($id); // Name field $name = new Text('name', ['placeholder' => $t->gettext('Name')]); $name->setLabel($t->gettext('Name')); $name->addValidators([new PresenceOf(['message' => $t->gettext('Name is required')])]); $this->add($name); // Email field $email = new Text('email', ['placeholder' => $t->gettext('Email')]); $email->setLabel($t->gettext('Email')); $email->addValidators([new PresenceOf(['message' => $t->gettext('Email is required')]), new Email(['message' => $t->gettext('Email is not valid')])]); $this->add($email); // rolesId field $roles = Roles::find(['active = :active:', 'bind' => ['active' => 'Y']]); $role = new Select('rolesId', $roles, ['using' => ['id', 'name'], 'useEmpty' => true, 'emptyText' => '...', 'emptyValue' => '']); $role->setLabel($t->gettext('Role')); $role->addValidators([new PresenceOf(['message' => $t->gettext('The user role must be set.')])]); $this->add($role); // active field $active = new Select('active', ['N' => $t->gettext('No'), 'Y' => $t->gettext('Yes')]); $active->setLabel($t->gettext('Active')); $this->add($active); // banned field $banned = new Select('banned', ['Y' => $t->gettext('Yes'), 'N' => $t->gettext('No')]); $banned->setLabel($t->gettext('Banned')); $this->add($banned); // emailActivationMsg field $emailExtraMsg = new Textarea('emailActivationMsg', ['placeholder' => $t->gettext('Add text to send confirmation email.')]); $emailExtraMsg->setLabel($t->gettext('Send activation email')); $this->add($emailExtraMsg); // Submit $submit = new Submit('submit', ['value' => $t->gettext('Save')]); $this->add($submit); }