/** * Constructor * * Instantiate the form object * * @param array $fields * @param string $action * @param string $method * @return Role */ public function __construct(array $fields = null, $action = null, $method = 'post') { parent::__construct($fields, $action, $method); $this->setAttribute('id', 'role-form'); $this->setAttribute('class', 'data-form'); $this->setIndent(' '); }
/** * Constructor * * Instantiate the form object * * @param array $fields * @param string $action * @param string $method * @return Install */ public function __construct(array $fields, $action = null, $method = 'post') { $fields[0]['db_adapter']['value'] = $this->getDbAdapters(); parent::__construct($fields, $action, $method); $this->setAttribute('id', 'install-form'); $this->setIndent(' '); }
/** * Constructor * * Instantiate the form object * * @param string $config * @param array $fields * @param string $action * @param string $method * @return InstallConfig */ public function __construct($config, array $fields, $action = null, $method = 'post') { $fields[0]['config']['value'] = $config; parent::__construct($fields, $action, $method); $this->setAttribute('id', 'install-config-form'); $this->setIndent(' '); }
/** * Constructor * * Instantiate the form object * * @param boolean $captcha * @param boolean $csrf * @param array $fields * @param string $action * @param string $method * @return Register */ public function __construct($captcha = false, $csrf = false, array $fields = null, $action = null, $method = 'post') { if ($csrf) { $fields[2] = array_merge(['csrf' => ['type' => 'csrf']], $fields[2]); } if ($captcha) { $fields[2] = array_merge(['captcha' => ['type' => 'captcha', 'label' => 'Please Solve:']], $fields[2]); } parent::__construct($fields, $action, $method); $this->setAttribute('id', 'register-form'); $this->setIndent(' '); }
/** * Constructor method to instantiate the form object * * @param string $action * @param string $method * @return self */ public function __construct($action = null, $method = 'post') { $lang = isset($_GET['lang']) ? $_GET['lang'] : 'en_US'; if (!defined('POP_LANG')) { define('POP_LANG', $lang); } $this->i18n = I18n::factory(); $this->i18n->loadFile(__DIR__ . '/../../../data/assets/i18n/' . $this->i18n->getLanguage() . '.xml'); $this->initFieldsValues = $this->getInitFields(); parent::__construct($action, $method, null, ' '); $this->setAttributes('id', 'install-form'); }
/** * Constructor * * Instantiate the form object * * @param int $id * @param array $fields * @param string $action * @param string $method * @return SessionConfig */ public function __construct($id = null, array $fields, $action = null, $method = 'post') { $configs = \Phire\Sessions\Table\UserSessionConfig::findAll(); $configsAry = []; foreach ($configs->rows() as $config) { $configsAry[] = $config->role_id; } $roles = Table\Roles::findAll(); $roleValues = ['----' => '----']; foreach ($roles->rows() as $role) { if (!in_array($role->id, $configsAry) || $id == $role->id) { $roleValues[$role->id] = $role->name; } } $fields[0]['role_id']['value'] = $roleValues; parent::__construct($fields, $action, $method); $this->setAttribute('id', 'session-form'); $this->setIndent(' '); }
/** * Constructor * * Instantiate the form object * * @param array $fields * @param string $action * @param string $method * @return Category */ public function __construct(array $fields, $action = null, $method = 'post') { parent::__construct($fields, $action, $method); $this->setAttribute('id', 'category-form'); $this->setIndent(' '); }
/** * Constructor * * Instantiate the form object * * @param array $fields * @param string $action * @param string $method * @return Unsubscribe */ public function __construct(array $fields, $action = null, $method = 'post') { parent::__construct($fields, $action, $method); $this->setAttribute('id', isset(\Pop\Web\Session::getInstance()->member) ? 'unsubscribe-member-form' : 'unsubscribe-form'); $this->setIndent(' '); }
public function __construct(array $fields = null, $action = null, $method = 'post') { $fields = ['name' => ['type' => 'text', 'label' => 'Name (Optional)', 'attributes' => ['size' => 60]], 'comment' => ['type' => 'textarea', 'label' => 'Comment (Required)', 'required' => true, 'attributes' => ['rows' => 5, 'cols' => 65]], 'submit' => ['type' => 'submit', 'value' => 'Submit']]; parent::__construct($fields, $action, $method); }
public function __construct(array $fields = null, $action = null, $method = 'post') { $fields = ['name' => ['type' => 'text', 'label' => 'Name (Optional)', 'attributes' => ['size' => 60]], 'comment' => ['type' => 'textarea', 'label' => 'Comment (Required)', 'required' => true, 'attributes' => ['rows' => 5, 'cols' => 65], 'validators' => new LengthLte(160, 'The comment must be 160 characters or less.')], 'submit' => ['type' => 'submit', 'value' => 'Submit']]; parent::__construct($fields, $action, $method); }
/** * Constructor method to instantiate the form object * * @param mixed $id * @param array $captchaConfig * @throws \Pop\Form\Exception * @return self */ public function __construct($id, $captchaConfig = []) { $form = is_numeric($id) ? Table\Forms::findById($id) : Table\Forms::findBy(['name' => $id]); if (!isset($form->id)) { throw new \Pop\Form\Exception('That form does not exist.'); } if (!class_exists('Phire\\Fields\\Model\\Field')) { throw new \Pop\Form\Exception('The phire-fields module is not installed or active.'); } $fieldGroups = []; $submitAttributes = []; $formAttributes = []; $this->filter = (bool) $form->filter; if (!empty($form->submit_attributes)) { $attribs = explode('" ', $form->submit_attributes); foreach ($attribs as $attrib) { $attAry = explode('=', $attrib); $att = trim($attAry[0]); $val = str_replace('"', '', trim($attAry[1])); $submitAttributes[$att] = $val; } } if (!empty($form->attributes)) { $attribs = explode('" ', $form->attributes); foreach ($attribs as $attrib) { $attAry = explode('=', $attrib); $att = trim($attAry[0]); $val = str_replace('"', '', trim($attAry[1])); $formAttributes[$att] = $val; } } $sql = \Phire\Fields\Table\Fields::sql(); $sql->select()->where('models LIKE :models'); $sql->select()->orderBy('order', 'ASC'); $value = $sql->getDbType() == \Pop\Db\Sql::SQLITE ? '%Phire\\Forms\\Model\\Form%' : '%Phire\\\\Forms\\\\Model\\\\Form%'; $fields = \Phire\Fields\Table\Fields::execute((string) $sql, ['models' => $value]); foreach ($fields->rows() as $field) { if (null !== $field->group_id) { $fieldGroups[$field->group_id] = []; } } $fieldGroups[0] = []; $fieldGroups[-1] = []; foreach ($fields->rows() as $field) { $field->validators = unserialize($field->validators); $field->models = unserialize($field->models); if (null !== $field->group_id) { foreach ($field->models as $model) { if (null === $model['type_value'] || $form->id == $model['type_value']) { $fieldConfig = \Phire\Fields\Event\Field::createFieldConfig($field); if (strpos($fieldConfig['label'], '<span class="editor-link-span">') !== false) { $fieldConfig['label'] = str_replace('<span class="editor-link-span">', '<span style="display: none;" class="editor-link-span">', $fieldConfig['label']); } $fieldGroups[$field->group_id]['field_' . $field->id] = $fieldConfig; break; } } } else { if (null === $field->group_id) { foreach ($field->models as $model) { if (null === $model['type_value'] || $form->id == $model['type_value']) { $fieldConfig = \Phire\Fields\Event\Field::createFieldConfig($field); if (strpos($fieldConfig['label'], '<span class="editor-link-span">') !== false) { $fieldConfig['label'] = str_replace('<span class="editor-link-span">', '<span style="display: none;" class="editor-link-span">', $fieldConfig['label']); } $fieldGroups[0]['field_' . $field->id] = $fieldConfig; break; } } } } } if ($form->use_csrf) { $fieldGroups[-1]['csrf'] = ['type' => 'csrf']; } if ($form->use_captcha) { if (class_exists('Phire\\Captcha\\Model\\Captcha')) { $captcha = new \Phire\Captcha\Model\Captcha($captchaConfig); $captcha->createToken(); $fieldGroups[-1]['captcha'] = ['type' => 'captcha', 'label' => 'Enter Code', 'token' => $captcha->token]; } else { $fieldGroups[-1]['captcha'] = ['type' => 'captcha', 'label' => 'Please Solve: ']; } } $fieldGroups[-1]['id'] = ['type' => 'hidden', 'value' => $form->id]; $fieldGroups[-1]['submit'] = ['type' => 'submit', 'label' => ' ', 'value' => !empty($form->submit_value) ? $form->submit_value : 'SUBMIT', 'attributes' => $submitAttributes]; parent::__construct($fieldGroups, null, $form->method); foreach ($formAttributes as $attrib => $value) { $this->setAttribute($attrib, $value); } }
public function __construct(array $fields = null, $action = null, $method = 'post') { $fields = ['username' => ['type' => 'text', 'required' => 'true', 'validators' => new Validator\NotEmpty(), 'attributes' => ['placeholder' => 'Username', 'size' => 40]], 'password' => ['type' => 'password', 'required' => 'true', 'validators' => new Validator\NotEmpty(), 'attributes' => ['placeholder' => 'Password', 'size' => 40]], 'submit' => ['type' => 'submit', 'value' => 'Login', 'attributes' => ['class' => 'save-btn']]]; parent::__construct($fields, $action, $method); $this->setAttribute('id', 'login-form'); }