function initialize($entity = null, $options = null) { $date = new Date('date'); $date->setLabel('Input Date'); $date->setFilters(array('striptags', 'string')); $date->setDefault(date('Y-m-d')); $date->addValidators(array(new PresenceOf(array('message' => 'Date is required')))); $this->add($date); $start_time = new Text('start_hour'); $start_time->setLabel('Input Start Hour'); $start_time->setFilters(array('striptags', 'string')); $start_time->addValidators(array(new PresenceOf(array('message' => 'Start Time is required')))); $this->add($start_time); $finish_time = new Text('finish_hour'); $finish_time->setLabel('Input Finish Hour'); $finish_time->setFilters(array('striptags', 'string')); $finish_time->addValidators(array(new PresenceOf(array('message' => 'Finish Time is required')))); $this->add($finish_time); $systemId = new Select('system_id', Systems::find(), array('using' => array('id', 'name'), 'useEmpty' => true)); $systemId->setLabel('Select System'); $systemId->addValidators(array(new PresenceOf(array('message' => 'System is required')))); if ($entity) { $systemId->setDefault(array($entity->system_id)); } $this->add($systemId); $description = new TextArea('description'); $description->setLabel('Input Description'); $description->addValidators(array(new PresenceOf(array('message' => 'Description is required')))); $this->add($description); $hidden = new Hidden('id'); if ($entity) { $hidden->setDefault(array($entity->id)); } $this->add($hidden); }
public function initialize($entity = null, $options = null) { $sortBy = new Select('sortBy', array('created_at' => 'Creation Date', 'price' => 'Price'), array('placeholder' => 'Sort By')); $sortBy->addValidators(array(new PresenceOf(array('message' => 'The Sort By is required')), new InclusionIn(array('message' => 'The sort by must be price or creation date', 'domain' => array('price', 'created_at'))))); $this->add($sortBy); $order = new Select('order', array('ASC' => 'Asc', 'DESC' => 'Desc'), array('placeholder' => 'Order')); $order->addValidators(array(new PresenceOf(array('message' => 'The order is required')), new InclusionIn(array('message' => 'The order must be asc or desc', 'domain' => array('ASC', 'DESC'))))); $this->add($order); // Add button $this->add(new Submit('sort', array('class' => 'btn btn-success'))); }
/** * 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); }
public function initialize($entity = null, $options = null) { // Make $make = new Text("make"); $make->setLabel('Make'); $make->addValidators(array(new PresenceOf(array('message' => 'Enter your car make')))); $this->add($make); // Model $model = new Text("model"); $model->setLabel('Model'); $model->addValidators(array(new PresenceOf(array('message' => 'Enter your car model')))); $this->add($model); // Year $year_options = array(); for ($i = date('Y'); $i > date('Y') - 100; $i--) { $years[$i] = $i; } $year = new Select("year", $years); $year->setLabel('Year'); $year->addValidators(array(new PresenceOf(array('message' => 'Select the year your car was registered')))); $this->add($year); //Colour $colour = new Text("colour"); $colour->setLabel('Colour'); $colour->addValidators(array(new PresenceOf(array('message' => 'Choose a colour')))); $this->add($colour); // Mileage $mileage = new Text("mileage"); $mileage->setLabel('Mileage (miles)'); $mileage->addValidators(array(new PresenceOf(array('message' => 'Enter your car\'s current mileage')))); $this->add($mileage); // Fuel $fuel = new Text("fuel"); $fuel->setLabel('Fuel'); $fuel->addValidators(array(new PresenceOf(array('message' => 'Tell us which fuel your car runs on')))); $this->add($fuel); // Engine Size $engine_cc = new Text("engine_cc"); $engine_cc->setLabel('Engine size (cc)'); $engine_cc->addValidators(array(new PresenceOf(array('message' => 'Tell us how many CC your engine is')))); $this->add($engine_cc); // Price $price = new Text("price"); $price->setLabel('Price (GBP)'); $price->addValidators(array(new PresenceOf(array('message' => 'Please enter a sale price')))); $this->add($price); // Postcode $postcode = new Text("postcode"); $postcode->setLabel('Postcode'); $postcode->addValidators(array(new PresenceOf(array('message' => 'Where is your car located?')))); $this->add($postcode); // ID $ID = new Hidden("ID"); $ID->setAttribute("value", ""); $this->add($ID); // Lat $lat = new Hidden("lat"); $lat->setAttribute("value", "0"); $this->add($lat); // Lng $lng = new Hidden("lng"); $lng->setAttribute("value", "0"); $this->add($lng); }
function initialize($entity = null, $options = null) { $date = new Date('date_found'); $date->setLabel('Input Date Found'); $date->setFilters(array('striptags', 'string')); $this->add($date); /*====================== Number =====================*/ $number = new Text('number'); $number->setLabel('Input Number'); $number->setFilters(array('striptags', 'string')); $number->addValidators(array(new PresenceOf(array('message' => 'Number is required')))); $this->add($number); /*====================== Solved =====================*/ $isSolved = new Radio('is_solved', array('name' => 'is_solved', 'value' => '1')); $isSolved->setLabel('Is Solved'); $isSolved->addValidators(array(new PresenceOf(array('message' => 'Is solved is required')))); $this->add($isSolved); $isSolved2 = new Radio('is_solved2', array('name' => 'is_solved', 'value' => '0', 'checked' => TRUE)); $isSolved2->setLabel('Is Solved2'); $isSolved2->addValidators(array(new PresenceOf(array('message' => 'Is solved is required')))); $this->add($isSolved2); $systemId = new Select('system_id', Systems::find(), array('using' => array('id', 'name'), 'useEmpty' => true)); $systemId->setLabel('Select System'); $systemId->addValidators(array(new PresenceOf(array('message' => 'System is required')))); if ($entity) { $systemId->setDefault(array($entity->system_id)); } $this->add($systemId); $modulesId = new Select('modules_id', Modules::find(), array('using' => array('id', 'name'), 'useEmpty' => true)); $modulesId->setLabel('Select Modules'); $modulesId->addValidators(array(new PresenceOf(array('message' => 'Modules is required')))); if ($entity) { $modulesId->setDefault(array($entity->modules_id)); } $this->add($modulesId); /*===== Bug =============*/ $systemId = new Select('system_id', Systems::find(), array('using' => array('id', 'name'), 'useEmpty' => true)); $systemId->setLabel('Select System'); $systemId->addValidators(array(new PresenceOf(array('message' => 'System is required')))); if ($entity) { $systemId->setDefault(array($entity->system_id)); } $this->add($systemId); $description = new TextArea('description'); $description->setLabel('Input Description'); $description->addValidators(array(new PresenceOf(array('message' => 'Description is required')))); $this->add($description); $hidden = new Hidden('id'); if ($entity) { $hidden->setDefault(array($entity->id)); } $this->add($hidden); }