public function addElements() { //-- E-mail current ------------------------------------ $email_current = new Element\Email('email_current'); $email_current->setAttribute('readonly', 'true'); $email_current->setAttribute('class', 'form-control'); $email_current->setAttribute('id', 'email-old'); $email_current->setLabel('Current'); $email_current->setLabelAttributes(array('class' => 'control-label', 'for' => 'email-current')); //-- E-mail new --------------------------------------- $email = new Element\Email('email'); $email->setAttribute('placeholder', '*****@*****.**'); $email->setAttribute('required', 'true'); $email->setAttribute('class', 'form-control'); $email->setAttribute('id', 'email'); $email->setLabel('New'); $email->setLabelAttributes(array('class' => 'control-label', 'for' => 'email')); //-- Submit ------------------------------------- $submit = new Element\Submit('submit'); $submit->setAttribute('class', 'btn btn-success'); $submit->setValue('Send'); // Binding elements $this->add($email_current); $this->add($email); $this->add($submit); }
public function __construct($name = null) { parent::__construct('users'); $this->setAttribute('class', 'form-small'); $this->setAttribute('method', 'post'); $this->setAttribute('novalidate', true); $csrf = new Element\Csrf('csrf'); $csrf_options = array('csrf_options' => array('timeout' => 1000)); $csrf->setAttribute('id', 'csrf'); $csrf->setOptions($csrf_options); $email = new Element\Email('email'); $email->setLabel('Email')->setAttribute('id', 'email')->setAttribute('class', 'form-control')->setAttribute('maxlength', '200')->setAttribute('required', true)->setAttribute('placeholder', 'Email address'); $password = new Element\Password('password'); $password->setLabel('Password')->setAttribute('id', 'password')->setAttribute('class', 'form-control')->setAttribute('maxlength', '200')->setAttribute('required', true)->setAttribute('placeholder', 'Password'); // $rememberme = new Element\Checkbox('rememberme'); // $rememberme->setLabel(' Remember me') // ->setAttribute('id', 'rememberme') // ->setAttribute('class', '') // ->setValue('1'); $submit = new Element\Submit('submit'); $submit->setValue('Log in')->setAttribute('id', 'submit')->setAttribute('class', 'btn btn-lg btn-primary btn-block'); $this->add($csrf); $this->add($email); $this->add($password); // $this->add($rememberme); $this->add($submit); }
public function prepareElements(array $categories) { $category = new Element\Select('category'); $category->setLabel('Category')->setOptions(array('options' => $categories)); $title = new Element\Text('title'); $title->setLabel('Title')->setAttribute('title', 'Enter a suitable title for this posting')->setAttribute('size', 40)->setAttribute('maxlength', 128); $priceMin = new Element\Text('priceMin'); $priceMin->setLabel('Minimum Price')->setAttribute('title', 'Enter mininum price as nnn.nn')->setAttribute('size', 16)->setAttribute('maxlength', 16); $priceMax = new Element\Text('priceMax'); $priceMax->setLabel('Maximum Price')->setAttribute('title', 'Enter maximum price as nnn.nn')->setAttribute('size', 16)->setAttribute('maxlength', 16); $expires = new Element\Date('expires'); $expires->setLabel('Expires')->setAttribute('title', 'The expiration date will be calculated from today')->setAttribute('size', 20)->setAttribute('maxlength', 20); $city = new Element\Text('city'); $city->setLabel('Nearest City')->setAttribute('title', 'Select the city of the item')->setAttribute('size', 40)->setAttribute('maxlength', 255); $country = new Element\Text('country'); $country->setLabel('Country Code')->setAttribute('title', 'Enter the 2 character ISO2 country code of the item')->setAttribute('size', 2)->setAttribute('maxlength', 2); $name = new Element\Text('name'); $name->setLabel('Contact Name')->setAttribute('title', 'Enter the name of the person to contact for this item')->setAttribute('size', 40)->setAttribute('maxlength', 255); $phone = new Element\Text('phone'); $phone->setLabel('Contact Phone Number')->setAttribute('title', 'Enter the phone number of the person to contact for this item')->setAttribute('size', 20)->setAttribute('maxlength', 32); $email = new Element\Email('email'); $email->setLabel('Contact Email')->setAttribute('title', 'Enter the email address of the person to contact for this item')->setAttribute('size', 40)->setAttribute('maxlength', 255); $description = new Element\Textarea('description'); $description->setLabel('Description')->setAttribute('title', 'Enter a suitable description for this posting')->setAttribute('rows', 4)->setAttribute('cols', 80); $submit = new Element\Submit('submit'); $submit->setAttribute('value', 'Search')->setAttribute('title', 'Click here when done'); $this->add($category)->add($title)->add($priceMin)->add($priceMax)->add($expires)->add($city)->add($country)->add($name)->add($phone)->add($email)->add($description)->add($submit); }
public function __construct() { parent::__construct(); $this->setAttribute('method', 'post'); $this->setAttribute('class', 'panel-body'); $mail = new Email('email'); $mail->setLabel('email'); $mail->setAttribute('class', 'form-control'); $this->add($mail); $captcha = new Captcha('register_captcha'); $imageAdapter = new Image(['font' => __DIR__ . '/../../fonts/arial.ttf']); $imageAdapter->setHeight(100); $imageAdapter->setWidth(400); $imageAdapter->setFontSize(48); $imageAdapter->setDotNoiseLevel(400); $imageAdapter->setLineNoiseLevel(40); $captcha->setCaptcha($imageAdapter); $captcha->setLabel('enter.text.from.the.picture'); $captcha->setAttribute('class', 'form-control'); $this->add($captcha); $submit = new Submit('send'); $submit->setValue('send'); $submit->setAttribute('class', 'btn btn-primary'); $this->add($submit); }
public function __construct($name = null) { parent::__construct('datbaseform'); $this->setAttribute('class', 'p-t-15'); $this->setAttributes(array('id' => 'form-datos-bd', 'class' => 'form-horizontal')); $username = new Element('username'); $username->setLabel('Nombre de Usuario:')->setLabelAttributes(array('class' => 'col-sm-3 control-label')); $username->setAttributes(array('type' => 'text', 'placeholder' => 'ej. Admin', 'id' => 'username', 'class' => 'form-control', 'data-rule-required' => "true", 'data-msg-required' => "Este campo debe estar lleno", 'data-rule-minlength' => "6", 'data-msg-minlength' => "Debe tener al menos 6 caracteres")); $password = new Element\Password('password'); $password->setLabel('Contraseña:')->setLabelAttributes(array('class' => 'col-sm-3 control-label required')); $password->setAttributes(array('placeholder' => 'No uses 1234 ;)', 'id' => 'password', 'class' => 'form-control', 'data-rule-required' => "true", 'data-msg-required' => "Este campo debe estar lleno")); $confirmaPassword = new Element\Password('confirmaPassword'); $confirmaPassword->setLabel(' ')->setLabelAttributes(array('class' => 'col-sm-3 control-label')); $confirmaPassword->setAttributes(array('placeholder' => 'Por seguridad este campo es necesario', 'id' => 'confirmaPassword', 'class' => 'form-control')); $email = new Element\Email('email'); $email->setLabel('Correo Electrónico:')->setLabelAttributes(array('class' => 'col-sm-3 control-label')); $email->setAttributes(array('placeholder' => '*****@*****.**', 'id' => 'email', 'class' => 'form-control')); $buttonContinuar = new Element\Button('buttonContinuar'); $buttonContinuar->setLabel('Instalar'); $buttonContinuar->setAttributes(array('class' => 'btn btn-success', 'type' => 'submit', 'id' => 'buttonContinuar')); $buttonLimpiar = new Element\Button('buttonLimpiar'); $buttonLimpiar->setLabel('<i class="pg-close"></i> Limpiar')->setLabelOptions(array('disable_html_escape' => true)); $buttonLimpiar->setAttributes(array('class' => 'btn btn-default', 'id' => 'buttonLimpiar', 'type' => 'reset')); $this->add($username); $this->add($password); $this->add($email); $this->add($confirmaPassword); $this->add($buttonContinuar); $this->add($buttonLimpiar); }
public function buildForm() { $this->setAttribute('method', 'POST'); $category = new Select('category'); $category->setLabel('Category')->setValueOptions(array_combine($this->getCategories(), $this->getCategories())); $title = new Text('title'); $title->setLabel('Title')->setAttributes(array('size' => 50, 'maxLength' => 128, 'required' => 'required', 'placeholder' => 'Title', 'title' => 'Title')); $photo = new Text('photo_filename'); $photo->setLabel('Photo')->setAttribute('maxlength', 1024)->setAttribute('placeholder', 'Enter a valid image file URL'); $name = new Text('contact_name'); $name->setLabel('Contact Name')->setAttribute('title', 'Contact Name')->setAttribute('size', 50)->setAttribute('maxlength', 255); $email = new Email('contact_email'); $email->setLabel('Contact Email')->setAttribute('title', 'Contact Email')->setAttribute('size', 50)->setAttribute('maxlength', 255); $phone = new Text('contact_phone'); $phone->setLabel('Contact Phone Number')->setAttribute('title', 'Contact Phone Number')->setAttribute('size', 20)->setAttribute('maxlength', 32); $city = new Select('cityCode'); $city->setLabel('Nearest City')->setValueOptions(array_combine(self::$cityCodes, self::$cityCodes))->setAttribute('id', 'cityCode'); $price = new Text('price'); $price->setLabel('Price')->setAttribute('title', 'Price as nnn.nn')->setAttribute('size', 16)->setAttribute('maxlength', 16); $expires = new Radio('expires'); $expires->setLabel('Expires')->setAttribute('title', 'The expiration date from today')->setAttribute('class', 'expiresButton')->setValueOptions($this->getExpireDays()); $deleteCode = new Text('delete_code'); $deleteCode->setLabel('Delete Code')->setAttribute('title', 'Delete code for this item')->setAttribute('size', 16)->setAttribute('maxlength', 16); $description = new Textarea('description'); $description->setLabel('Description')->setAttribute('title', 'Description')->setAttribute('rows', 5)->setAttribute('cols', 80); $captchaAdapter = new ImageCaptcha(); $captchaAdapter->setWordlen(4)->setOptions($this->captchaOptions); $captcha = new Captcha('captcha'); $captcha->setCaptcha($captchaAdapter)->setLabel('Help us to prevent SPAM!')->setAttribute('class', 'captchaStyle')->setAttribute('title', 'Help us to prevent SPAM'); $submit = new Submit('submit'); $submit->setAttribute('value', 'Post'); $this->add($category)->add($title)->add($photo)->add($name)->add($email)->add($phone)->add($city)->add($price)->add($expires)->add($deleteCode)->add($description)->add($captcha)->add($submit); }
public function __construct($name = 'mailchimp-sub-form', $options = array()) { parent::__construct($name, $options); $firstName = new Element\Text('firstName'); $firstName->setLabel('First Name'); $lastName = new Element\Text('lastName'); $lastName->setLabel('Last Name'); $email = new Element\Email('email'); $email->setLabel('Email Address'); $emailValidator = new Validator\EmailAddress(array('allow' => Validator\Hostname::ALLOW_DNS, 'domain' => true)); $email->setValidator($emailValidator); $privacyPolicy = new Element\Checkbox('privacyPolicy'); $privacyPolicy->setLabel('I accept the privacy policy and the terms of use'); $csrf = new Element\Csrf('mcSubCSRF'); $submit = new Element\Submit('submit'); $submit->setValue('Subscribe'); $this->add($firstName); $this->add($lastName); $this->add($email); $this->add($privacyPolicy); $this->add($csrf); $this->add($submit); $inputFilter = $this->getInputFilter(); $inputFilter->get($firstName->getName())->setAllowEmpty(false)->setRequired(true); $inputFilter->get($lastName->getName())->setAllowEmpty(false)->setRequired(true); }
public function __construct($name = null) { parent::__construct('users'); $this->setAttribute('class', ''); $this->setAttribute('method', 'post'); $id = new Element\Hidden('id'); $id->setAttribute('class', 'primarykey'); // $username = new Element\Text('username'); // $username->setLabel('User Name') // ->setAttribute('class', 'required inputfullwidth') // ->setAttribute('maxlength', '100') // ->setAttribute('placeholder', 'Username'); $email = new Element\Email('email'); $email->setLabel('Email')->setAttribute('class', 'required email inputfullwidth')->setAttribute('maxlength', '100')->setAttribute('placeholder', 'Email'); $password = new Element\Password('password'); $password->setLabel('Password')->setAttribute('class', 'required passValid inputfullwidth')->setAttribute('id', 'inputPassword')->setAttribute('maxlength', '100')->setAttribute('min', '6')->setAttribute('placeholder', 'Password'); $repassword = new Element\Password('repassword'); $repassword->setLabel('Confirm Password')->setAttribute('class', 'required inputfullwidth')->setAttribute('id', 'inputPassword')->setAttribute('maxlength', '100')->setAttribute('min', '6')->setAttribute('placeholder', 'Confirm Password'); $first_name = new Element\Text('first_name'); $first_name->setLabel('First Name')->setAttribute('class', 'required inputfullwidth')->setAttribute('maxlength', '100')->setAttribute('placeholder', 'First Name'); $last_name = new Element\Text('last_name'); $last_name->setLabel('Last Name')->setAttribute('class', 'required inputfullwidth')->setAttribute('maxlength', '100')->setAttribute('placeholder', 'Last Name'); $submit = new Element\Submit('submit'); $submit->setValue('Join Now')->setAttribute('class', 'btn btn-large btn-success btn-hossbrag join-now-home fullwidth'); $this->add($id); $this->add($first_name); $this->add($last_name); // $this->add($username); $this->add($email); $this->add($password); $this->add($repassword); $this->add($submit); }
public function __construct() { parent::__construct('value'); $this->setHydrator(new ArraySerializableHydrator(false)); $adress_text = new Element\Email('value'); $adress_text->setAttributes(array('class' => 'type_text_input', 'placeholder' => 'Type adress in format', 'required' => true)); $adress_text->setLabel('Email'); $this->add($adress_text); $this->add(array('type' => 'Button', 'name' => 'submit', 'options' => array('label' => 'delete'), 'attributes' => array('class' => 'btn btn btn_red3'))); }
public function prepare() { if ($this->isPrepared) { return $this; } $email = new Email('email'); $email->setLabel('Email'); $password = new Password('password'); $password->setLabel('Password'); $submit = new Submit('login'); $submit->setValue('Login'); $this->add($email)->add($password)->add($submit); return parent::prepare(); }
public function indexAction() { $form = new Form(); // Элемент Date/Time $dateTime = new Element\DateTime('element-date-time'); $dateTime->setLabel('Date/Time Element')->setAttributes(array('min' => '2000-01-01T00:00:00Z', 'max' => '2020-01-01T00:00:00Z', 'step' => '1')); $form->add($dateTime); // Элемент Date/Time Local $dateTime = new Element\DateTimeLocal('element-date-time-local'); $dateTime->setLabel('Date/Time Local Element')->setAttributes(array('min' => '2000-01-01T00:00:00Z', 'max' => '2020-01-01T00:00:00Z', 'step' => '1')); $form->add($dateTime); // Элемент Time $time = new Element\Time('element-time'); $time->setLabel('Time Element'); $form->add($time); // Элемент Date $date = new Element\Date('element-date'); $date->setLabel('Date Element')->setAttributes(array('min' => '2000-01-01', 'max' => '2020-01-01', 'step' => '1')); $form->add($date); // Элемент Week $week = new Element\Week('element-week'); $week->setLabel('Week Element'); $form->add($week); // Элемент Month $month = new Element\Month('element-month'); $month->setLabel('Month Element'); $form->add($month); // Элемент Email $email = new Element\Email('element-email'); $email->setLabel('Email Element'); $form->add($email); // Элемент URL $url = new Element\Url('element-url'); $url->setLabel('URL Element'); $form->add($url); // Элемент Number // $number = new Element\Number('element-number'); // $number->setLabel('Number Element'); // $form->add($number); // Элемент Range // $range = new Element\Range('element-range'); // $range->setLabel('Range Element'); // $form->add($range); // Элемент Color $color = new Element\Color('element-color'); $color->setLabel('Color Element'); $form->add($color); return array('form' => $form); }
public function init() { $element = new Text('prenom'); $element->setLabel('Prénom'); $this->add($element); $element = new Text('nom'); $element->setLabel('Nom'); $this->add($element); $element = new Email('email'); $element->setLabel('Email'); $this->add($element); $element = new Text('telephone'); $element->setLabel('Téléphone'); $this->add($element); $this->add(array('type' => 'DoctrineModule\\Form\\Element\\ObjectSelect', 'name' => 'societe', 'options' => array('object_manager' => $this->getObjectManager(), 'target_class' => Societe::class, 'property' => 'nom', 'display_empty_item' => true, 'label' => 'Société', 'empty_item_label' => '-- Pas de société --'))); }
public function __construct($name = null) { parent::__construct('users'); $this->setAttribute('class', 'form-small'); $this->setAttribute('method', 'post'); $this->setAttribute('novalidate', true); $username = new Element\Text('username'); $username->setLabel('User Name')->setAttribute('class', '')->setAttribute('id', 'username')->setAttribute('placeholder', 'Enter Your Username'); $email = new Element\Email('email'); $email->setLabel('Email')->setAttribute('id', 'email')->setAttribute('class', 'form-control')->setAttribute('maxlength', '200')->setAttribute('required', true)->setAttribute('placeholder', 'Enter your email address'); $submit = new Element\Submit('submit'); $submit->setValue('Submit')->setAttribute('id', 'submit')->setAttribute('class', 'btn btn-lg btn-primary btn-block mrg-top-10'); $this->add($username); $this->add($email); $this->add($submit); }
public function addElements() { //-- Profile name ---------------------------------- $login = new Element\Text('profile_name'); $login->setAttribute('placeholder', 'profile_name'); $login->setAttribute('required', 'true'); $login->setAttribute('class', 'form-control'); $login->setAttribute('id', 'profile-name'); $login->setLabel('Profile name'); $login->setLabelAttributes(array('class' => 'control-label', 'for' => 'profile-name')); //-- E-mail --------------------------------------- $email = new Element\Email('email'); $email->setAttribute('placeholder', '*****@*****.**'); $email->setAttribute('required', 'true'); $email->setAttribute('class', 'form-control'); $email->setAttribute('id', 'email'); $email->setLabel('E-mail'); $email->setLabelAttributes(array('class' => 'control-label', 'for' => 'email')); //-- Password ------------------------------------ $password = new Element\Password('password'); $password->setAttribute('placeholder', '*****'); $password->setAttribute('required', 'true'); $password->setAttribute('class', 'form-control'); $password->setAttribute('id', 'password'); $password->setLabel('Password'); $password->setLabelAttributes(array('class' => 'control-label', 'for' => 'password')); //-- Password (confirm) --------------------------- $password_confirm = new Element\Password('confirm_password'); $password_confirm->setAttribute('placeholder', '*****'); $password_confirm->setAttribute('required', 'true'); $password_confirm->setAttribute('class', 'form-control'); $password_confirm->setAttribute('id', 'confirm-password'); $password_confirm->setLabel('Confirm password'); $password_confirm->setLabelAttributes(array('class' => 'control-label', 'for' => 'confirm_password')); //-- Submit ------------------------------------- $submit = new Element\Submit('submit'); $submit->setAttribute('class', 'btn btn-success'); $submit->setValue('Send'); // Binding elements $this->add($login); $this->add($email); $this->add($password); $this->add($password_confirm); $this->add($submit); }
public function __construct($name = null) { parent::__construct(__CLASS__); $this->setAttribute('method', 'post'); $this->setAttribute('enctype', 'multipart/form-data'); $name = new Element\Hidden('id'); $this->add($name); $name = new Element\Text('name'); $name->setLabel("Full Name"); $this->add($name); $email = new Element\Email('email'); $email->setLabel("Email"); $email->setAttribute('required', 'required'); $this->add($email); $submit = new Element\Submit('submit'); $submit->setValue("submit")->setLabel("submit"); $this->add($submit); }
public function __construct() { parent::__construct(); $this->setAttribute('method', 'post'); $this->setAttribute('class', 'panel-body'); $username = new Text('username'); $username->setLabel('username'); $username->setAttribute('class', 'form-control'); $username->setAttribute('data-urr', '/isusernameinuse'); $this->add($username); $mail = new Email('email'); $mail->setLabel('email'); $mail->setAttribute('class', 'form-control'); $this->add($mail); $password = new Password('password'); $password->setLabel('password'); $password->setAttribute('class', 'form-control'); $this->add($password); $password2 = new Password('password2'); $password2->setLabel('repeat.password'); $password2->setAttribute('class', 'form-control'); $this->add($password2); $captcha = new Captcha('registerCaptcha'); $imageAdapter = new Image(['font' => __DIR__ . '/../../fonts/arial.ttf']); $imageAdapter->setHeight(100); $imageAdapter->setWidth(400); $imageAdapter->setFontSize(48); $imageAdapter->setDotNoiseLevel(400); $imageAdapter->setLineNoiseLevel(40); $captcha->setCaptcha($imageAdapter); $captcha->setLabel('enter.text.from.the.picture'); $captcha->setAttribute('class', 'form-control'); $this->add($captcha); $agb = new Checkbox('gtcAccept'); $agb->setLabel('accept.terms.of.gtc'); $agb->setAttribute('class', 'form-control'); $agb->setLabelAttributes(['class' => 'checkboxLabel']); $this->add($agb); $submit = new Submit('register'); $submit->setValue('register'); $submit->setAttribute('class', 'btn btn-primary'); $this->add($submit); }
public function __construct(ServiceLocatorInterface $serviceLocator, ObjectManager $objectManager) { parent::__construct('user-form'); $this->setAttribute('class', 'form-horizontal'); /** @var \Application\Filter\UserFilter $userFilter */ $userFilter = $serviceLocator->get("user-filter"); $this->setInputFilter($userFilter); $this->setObjectManager($objectManager); $translator = $serviceLocator->get('translator'); $id = new Hidden('id'); $this->add($id); $first_name = new Text('firstname'); $first_name->setLabel($translator->translate('First Name'))->setAttributes(['id' => 'user_first_name', 'class' => 'form-control input-circle']); $this->add($first_name); $last_name = new Text('lastname'); $last_name->setLabel($translator->translate('Last Name'))->setAttributes(['id' => 'user_last_name', 'class' => 'form-control input-circle']); $this->add($last_name); $username = new Text('username'); $username->setLabel($translator->translate('Username'))->setAttributes(['id' => 'user_username', 'class' => 'form-control input-circle']); $this->add($username); $email = new Email('email'); $email->setLabel($translator->translate('E-mail'))->setAttributes(['id' => 'user_email', 'class' => 'form-control input-circle']); $this->add($email); $password = new Password('password'); $password->setLabel($translator->translate('Password'))->setAttributes(['id' => 'user_password', 'class' => 'form-control input-circle', 'placeholder' => $translator->translate('Report to Update')]); $this->add($password); $level = new Select('level'); $level->setLabel($translator->translate('Level'))->setAttributes(['id' => 'user_level', 'class' => 'form-control select2me', 'options' => ['1' => $translator->translate('Super Admin'), '2' => $translator->translate('Admin'), '3' => $translator->translate('User')]]); $this->add($level); $ps = new Textarea('ps'); $ps->setLabel($translator->translate('PS'))->setAttributes(['id' => 'user_ps', 'class' => 'form-control input-circle', 'rows' => 5]); $this->add($ps); $language = new ObjectSelect('language'); $language->setLabel($translator->translate('Language'))->setAttributes(['id' => 'language', 'class' => 'form-control select2me'])->setOptions(['object_manager' => $this->getObjectManager(), 'target_class' => 'Application\\Entity\\WcLanguage', 'property' => 'name', 'empty_option' => $translator->translate('Select one Language'), 'is_method' => TRUE, 'find_method' => ['name' => 'findBy', 'params' => ['criteria' => [], 'orderBy' => ['name' => 'ASC']]]]); $this->add($language); $status = new Select('status'); $status->setLabel($translator->translate('Status'))->setAttributes(['id' => 'user_status', 'class' => 'form-control select2me', 'options' => ['1' => $translator->translate('Active'), '0' => $translator->translate('Desactive')]]); $this->add($status); $submit = new Button('submit'); $submit->setLabel($translator->translate('Save'))->setAttributes(['type' => 'submit', 'class' => 'btn-primary btn btn-circle pull-right ml-xs send']); $this->add($submit); }
public function prepare() { if ($this->isPrepared) { return $this; } $email = new Email('email'); $email->setLabel('Email'); $password = new Password('password'); $password->setLabel('P2assword'); $member = new Radio('memberOf'); $member->setValueOptions(array('__model.id__' => '__model.name__')); $memberOfTemplate = new TemplateCollection('memberOfTemplate'); $memberOfTemplate->setTargetElement($member); $memberOf = new Fieldset('memberOfGroup'); $memberOf->setLabel('Member of')->add($memberOfTemplate); $submit = new Submit('register'); $submit->setValue('Register'); $this->add($memberOf)->add($submit); return parent::prepare(); }
protected function addElements() { $username = new Element\Text('username'); $username->setLabel('Username'); $username->setAttribute('required', 'required'); $this->add($username); $email = new Element\Email('email'); $email->setLabel("Email"); $email->setAttribute('required', 'required'); $this->add($email); $password = new Element\Password('password'); $password->setLabel('password'); $password->setAttribute('required', 'required'); $this->add($password); $remember = new Element\Checkbox('rememberme'); $remember->setLabel('remember me'); $this->add($remember); $submit = new Element\Submit('submit'); $submit->setValue("submit")->setLabel("submit"); $this->add($submit); }
public function __construct(EntityManager $entityManager) { parent::__construct(); $this->entityManager = $entityManager; $this->setAttributes(array("method" => "post", "enctype" => "multipart/form-data", "class" => "form")); $this->setInputFilter(new UsuariosFilters()); // Campo de titulo $nome = new Text('nome'); $nome->setLabel("* Nome")->setAttributes(array("maxLength" => "200", "class" => "form-control", "required" => "required")); // Campo de email $email = new Email('email'); $email->setLabel("* E-mail")->setAttributes(array("maxLength" => "200", "class" => "form-control", "required" => "required")); // Campo de midia $file = new File("midia"); $file->setLabel('*Imagem (Tamanho exato de ' . \Base\Constant\Upload::PERFIL_WIDTH . 'x' . \Base\Constant\Upload::PERFIL_HEIGTH . ' px | ' . \Base\Constant\Upload::PERFIL_SIZE . ')')->setAttribute('name', 'midia')->setAttribute('id', 'image'); // Botão de Submit $botao = new Submit("submit"); $botao->setAttributes(array("value" => "Salvar")); // Adiciona campos $this->add($nome)->add($email)->add($file)->add($botao); }
public function getForm() { if (!$this->form) { $contactId = new Element\Hidden(); $contactId->setName('contactId'); $name = new Element\Text(); $name->setLabel('Name')->setName("name")->setAttribute('class', 'form-control'); $phone = new Element\Text(); $phone->setLabel('Phone')->setName("phone")->setAttribute('class', 'form-control'); $email = new Element\Email(); $email->setLabel('Email')->setName("email")->setAttribute('class', 'form-control'); $address = new Element\Textarea(); $address->setLabel('Address')->setName("address")->setAttribute('class', 'form-control'); $website = new Element\Url(); $website->setLabel('Website')->setName("website")->setAttribute('class', 'form-control'); $selectCompany = new Element\Select(); $selectCompany->setName('companyId')->setLabel('Company')->setAttribute('class', 'form-control')->setEmptyOption("---Choose Company---")->setValueOptions($this->companies); $notes = new Element\Textarea(); $notes->setLabel('Notes')->setName("notes")->setAttribute('class', 'form-control'); $tag = new Element\Text(); $tag->setLabel('Tag')->setName("tag")->setAttribute('class', 'form-control'); $status = new Element\Select(); $status->setName('status')->setLabel('Status')->setAttribute('class', 'form-control')->setValueOptions(array('A' => 'Active', 'D' => 'Inactive')); $form = new Form(); $form->setAttribute('class', 'form-horizontal'); $form->setAttribute('enctype', 'multipart/form-data'); $form->add($contactId); $form->add($name); $form->add($phone); $form->add($email); $form->add($address); $form->add($website); $form->add($selectCompany); $form->add($notes); $form->add($tag); $form->add($status); $this->form = $form; } return $this->form; }
/** * Categories will be retrieved from the service manager * @param array $captchaOptions */ public function buildForm() { /****************************************************************** * Isto é um exemplo de como realizar a configurações do formulario, * O importante é registrar o campos do formulário pedidos no exercícios **********************************************************************/ // form tag attributes $this->setAttribute('method', 'POST'); // define elements $category = new Element\Select('category'); $category->setLabel('Category')->setValueOptions(array_combine($this->getCategories(), $this->getCategories())); $title = new Element\Text('title'); $title->setLabel('Title')->setAttributes(array('size' => 60, 'maxLength' => 128, 'required' => 'required', 'placeholder' => 'Listing header')); $photo = new Element\Text('photo_filename'); $photo->setLabel('Photo')->setAttribute('maxlength', 1024)->setAttribute('placeholder', 'Enter URL of a JPG'); $price = new Element\Text('price'); $price->setLabel('Price')->setAttribute('title', 'Enter price as nnn.nn')->setAttribute('size', 16)->setAttribute('maxlength', 16)->setAttribute('placeholder', 'Enter some value'); $expires = new Element\Radio('expires'); $expires->setLabel('Expires')->setAttribute('title', 'The expiration date will be calculated from today')->setAttribute('class', 'expiresButton')->setValueOptions($this->getExpireDays()); $city = new Element\Text('cityCode'); $city->setLabel('Nearest City')->setAttribute('title', 'Select the city of the item')->setAttribute('id', 'cityCode')->setAttribute('placeholder', 'Start typing and choose the city'); $name = new Element\Text('contact_name'); $name->setLabel('Contact Name')->setAttribute('title', 'Enter the name of the person to contact for this item')->setAttribute('size', 40)->setAttribute('maxlength', 255); $phone = new Element\Text('contact_phone'); $phone->setLabel('Contact Phone Number')->setAttribute('title', 'Enter the phone number of the person to contact for this item')->setAttribute('size', 20)->setAttribute('maxlength', 32); $email = new Element\Email('contact_email'); $email->setLabel('Contact Email')->setAttribute('title', 'Enter the email address of the person to contact for this item')->setAttribute('size', 40)->setAttribute('maxlength', 255); $description = new Element\Textarea('description'); $description->setLabel('Description')->setAttribute('title', 'Enter a suitable description for this posting')->setAttribute('rows', 4)->setAttribute('cols', 80); $delCode = new Element\Text('delete_code'); $delCode->setLabel('Delete Code')->setAttribute('title', 'Enter the delete code for this item')->setAttribute('size', 16)->setAttribute('maxlength', 16); $captcha = new Element\Captcha('captcha'); $captchaAdapter = new ImageCaptcha(); $captchaAdapter->setWordlen(4)->setOptions($this->captchaOptions); $captcha->setCaptcha($captchaAdapter)->setLabel('Help us to prevent SPAM!')->setAttribute('class', 'captchaStyle')->setAttribute('title', 'Help to prevent SPAM'); $submit = new Element\Submit('submit'); $submit->setAttribute('value', 'Post'); $this->add($category)->add($title)->add($photo)->add($price)->add($expires)->add($city)->add($name)->add($phone)->add($email)->add($description)->add($delCode)->add($captcha)->add($submit); }
public function __construct(EntityManager $objectManager) { parent::__construct('auth'); $this->setAttribute('method', 'post'); $this->setAttributes(array('id' => 'auth', 'role' => 'form')); $this->setInputFilter(new UtilisateurForm($objectManager, UtilisateurForm::TYPE_EDIT)); // Email $email = new Email('email'); $email->setLabel('Adresse email')->setLabelAttributes(array('class' => 'control-label'))->setAttributes(array('id' => 'email', 'class' => 'form-control', 'placeholder' => 'Adresse email', 'required' => true)); $this->add($email); // Password $password = new Password('password'); $password->setLabel('Mot de passe')->setLabelAttributes(array('class' => 'control-label'))->setAttributes(array('id' => 'password', 'class' => 'form-control', 'placeholder' => 'Mot de passe', 'required' => true)); $this->add($password); // Password $password = new Password('passwordConfirmation'); $password->setLabel('Confirmation du mot de passe')->setLabelAttributes(array('class' => 'control-label'))->setAttributes(array('id' => 'passwordConfirmation', 'class' => 'form-control', 'placeholder' => 'Mot de passe', 'required' => true)); $this->add($password); // Submit $submit = new Submit('submit'); $submit->setValue('Modifier'); $submit->setAttributes(array('class' => 'btn btn-lg btn-primary btn-block')); $this->add($submit); }
public function __construct(array $roles) { parent::__construct(); $this->setAttribute('method', 'post'); $this->setAttribute('class', 'panel-body'); $username = new Text('username'); $username->setLabel('username'); $username->setAttribute('class', 'form-control'); $username->setAttribute('data-urr', '/isusernameinuse'); $this->add($username); $mail = new Email('email'); $mail->setLabel('email'); $mail->setAttribute('class', 'form-control'); $this->add($mail); $role = new Select('role'); $role->setLabel('role'); $role->setAttribute('class', 'form-control'); $role->setValueOptions($roles); $this->add($role); $submit = new Submit('save'); $submit->setValue('save'); $submit->setAttribute('class', 'btn btn-primary'); $this->add($submit); }
/** * Prepara os campos do formulário * @param string $fieldName * @param array $fieldParams * @param array $options * @return object * @throws Exception */ private function prepareFields($fieldName, array $fieldParams, array $options = array()) { $element = null; $extraLabel = " "; $this->aOptions = array(); $this->aAttributes = array(); /* Define o tooltip do campo */ $tooltip = (isset($fieldParams['tooltip']) and $fieldParams['tooltip'] == 'true') ? "<a class=\"tooltip-marc\" href=\"#\" data-toggle=\"tooltip\" title=\"{$this->getTranslator($fieldName . '_tooltip')}\">[?]</a>" : null; $this->aOptions['tooltip'] = $tooltip; /* Define como será mostrado o nome do campo (se é obrigatório ou não) */ if (strtolower($fieldParams['type']) != 'hidden') { if (isset($fieldParams['validation']) and stristr(strtolower($fieldParams['validation']), "required")) { $extraLabel = " * "; } } switch (strtolower($fieldParams['type'])) { /* Caso hidden */ case 'primary': case 'hidden': $element = new ZendFormElement\Hidden($fieldName); break; /* Caso Csrf */ /* Caso Csrf */ case 'csrf': case 'sec': $element = new ZendFormElement\Csrf($fieldName); $element->setCsrfValidatorOptions(array('timeout' => '600')); break; /* Caso text */ /* Caso text */ case 'text': $element = new ZendFormElement\Text($fieldName); $element->setLabel($this->getTranslator($fieldName) . $extraLabel); $this->aAttributes['class'] = 'form-input'; break; /* Caso textarea */ /* Caso textarea */ case 'textarea': $element = new ZendFormElement\Textarea($fieldName); $element->setLabel($this->getTranslator($fieldName) . $extraLabel); /* Define os padrões de colunas e linhas do campo */ $this->aAttributes['rows'] = (isset($fieldParams['rows']) and !empty($fieldParams['rows'])) ? $fieldParams['rows'] : 5; $this->aAttributes['cols'] = (isset($fieldParams['cols']) and !empty($fieldParams['cols'])) ? $fieldParams['cols'] : 10; $this->aAttributes['class'] = 'form-input'; $this->aAttributes['data-editor'] = 'false'; break; /* Caso editor */ /* Caso editor */ case 'editor': $element = new ZendFormElement\Textarea($fieldName); $element->setLabel($this->getTranslator($fieldName) . $extraLabel); /* Define os padrões de colunas e linhas do campo */ $this->aAttributes['rows'] = (isset($fieldParams['rows']) and !empty($fieldParams['rows'])) ? $fieldParams['rows'] : 5; $this->aAttributes['cols'] = (isset($fieldParams['cols']) and !empty($fieldParams['cols'])) ? $fieldParams['cols'] : 10; /* Verifica se utilizará o editor */ $this->aAttributes['class'] = 'editorw'; $this->aAttributes['data-editor'] = 'true'; /* Verifica a pasta de upload */ if (isset($this->formDefaultConfig['destination']) and !empty($this->formDefaultConfig['destination'])) { /* Caso não exista a pasta cria o mesmo */ if (!is_dir(UPLOAD_PATH . $this->formDefaultConfig['destination'])) { mkdir(UPLOAD_PATH . $this->formDefaultConfig['destination'], 0777, true); chmod(UPLOAD_PATH . $this->formDefaultConfig['destination'], 0777); } $_SESSION['KCFINDER'] = array(); $_SESSION['KCFINDER']['disabled'] = false; $_SESSION['KCFINDER']['uploadURL'] = URL_UPLOAD . $this->formDefaultConfig['destination']; $_SESSION['KCFINDER']['uploadDir'] = UPLOAD_PATH . $this->formDefaultConfig['destination']; } else { throw new \Exception('Defina a pasta de destino de upload das imagens do editor!', 500); } break; /* Caso password */ /* Caso password */ case 'password': $element = new ZendFormElement\Password($fieldName); $element->setLabel($this->getTranslator($fieldName) . $extraLabel); $this->aAttributes['renderPassword'] = true; $this->aAttributes['class'] = 'form-input'; break; /* Caso radio */ /* Caso radio */ case 'radio': $element = new ZendFormElement\Radio($fieldName); $element->setLabel($this->getTranslator($fieldName) . $extraLabel); $this->aAttributes['class'] = 'radio'; break; /* Caso checkbox */ /* Caso checkbox */ case 'checkbox': $element = new ZendFormElement\Checkbox($fieldName); $element->setLabel($this->getTranslator($fieldName) . $extraLabel); $element->setUncheckedValue(null); $this->aAttributes['class'] = 'checkbox'; break; /* Caso multicheckbox */ /* Caso multicheckbox */ case 'multicheckbox': $element = new ZendFormElement\MultiCheckbox($fieldName); $element->setLabel($this->getTranslator($fieldName) . $extraLabel); $element->setUncheckedValue(null); break; /* Caso select */ /* Caso select */ case 'select': $element = new ZendFormElement\Select($fieldName, array('disable_inarray_validator' => true)); $element->setLabel($this->getTranslator($fieldName) . $extraLabel); $this->selectOptions = array(); if (isset($fieldParams['placeholder']) and strtolower($fieldParams['placeholder']) == 'true') { $this->selectOptions[''] = $this->getTranslator($fieldName . '_placeholder'); } else { $this->selectOptions[''] = "---------"; } $this->aAttributes['class'] = 'form-input-select'; break; /* Caso selectgroup */ /* Caso selectgroup */ case 'selectgroup': $element = new ZendFormElement\Select($fieldName, array('disable_inarray_validator' => true)); $element->setLabel($this->getTranslator($fieldName) . $extraLabel); $this->selectOptions = array(); if (isset($fieldParams['placeholder']) and strtolower($fieldParams['placeholder']) == 'true') { $this->selectOptions[''] = $this->getTranslator($fieldName . '_placeholder'); } else { $this->selectOptions[''] = "---------"; } $this->aAttributes['class'] = 'form-input-select'; break; /* Caso multiselect */ /* Caso multiselect */ case 'multiselect': $element = new ZendFormElement\Select($fieldName, array('disable_inarray_validator' => true)); $element->setLabel($this->getTranslator($fieldName) . $extraLabel); $this->aAttributes['class'] = 'form-input-select ms'; $this->aAttributes['multiple'] = 'multiple'; break; /* Caso fileimage */ /* Caso fileimage */ case 'fileimage': $element = new ZendFormElement\File($fieldName); $element->setLabel($this->getTranslator($fieldName) . $extraLabel); //$this->aAttributes['multiple'] = true; $this->aAttributes['class'] = 'hiddenImageFile'; /* Verifica a pasta de upload */ if (isset($this->formDefaultConfig['pathfiles']) and !empty($this->formDefaultConfig['pathfiles'])) { /* Caso não exista a pasta cria o mesmo */ if (!is_dir(UPLOAD_PATH . $this->formDefaultConfig['pathfiles'])) { mkdir(UPLOAD_PATH . $this->formDefaultConfig['pathfiles'], 0777, true); chmod(UPLOAD_PATH . $this->formDefaultConfig['pathfiles'], 0777); } $this->aAttributes['data-path'] = LINK_DEFAULT . 'uploads/' . $this->formDefaultConfig['pathfiles']; } else { throw new \Exception('Defina a pasta de destino de upload das imagens do editor!', 500); } break; /* Caso file */ /* Caso file */ case 'file': $element = new ZendFormElement\File($fieldName); $element->setLabel($this->getTranslator($fieldName) . $extraLabel); break; case 'money': $element = new ZendFormElement\Text($fieldName); $element->setLabel($this->getTranslator($fieldName) . $extraLabel); $this->aAttributes['class'] = 'form-input'; break; /* HTML5 Elements */ /* Caso url */ /* HTML5 Elements */ /* Caso url */ case 'url': $element = new ZendFormElement\Url($fieldName); $element->setLabel($this->getTranslator($fieldName) . $extraLabel); $this->aAttributes['class'] = 'form-input'; break; /* Caso date */ /* Caso date */ case 'date': $element = new ZendFormElement\Date($fieldName); $element->setLabel($this->getTranslator($fieldName) . $extraLabel); $this->aAttributes['min'] = date("Y") - 10 . '-01-01'; $this->aAttributes['max'] = date("Y") + 10 . '-12-31'; $this->aAttributes['class'] = 'form-input'; break; case 'dateage': $element = new ZendFormElement\Date($fieldName); $element->setLabel($this->getTranslator($fieldName) . $extraLabel); $this->aAttributes['min'] = date("Y") - 100 . '-01-01'; $this->aAttributes['max'] = date("Y") + 100 . '-12-31'; $this->aAttributes['class'] = 'form-input'; break; /* Caso time */ /* Caso time */ case 'time': $element = new ZendFormElement\DateTime($fieldName); $element->setLabel($this->getTranslator($fieldName) . $extraLabel); $this->aAttributes['class'] = 'form-input'; $this->aAttributes['min'] = '00:00:00'; $this->aAttributes['max'] = '23:59:59'; $this->aOptions['format'] = 'H:i:s'; break; /* Caso date */ /* Caso date */ case 'datetime': $element = new ZendFormElement\DateTime($fieldName); $element->setLabel($this->getTranslator($fieldName) . $extraLabel); $this->aAttributes['min'] = date("Y") - 10 . '-01-01 00:00:00'; $this->aAttributes['max'] = date("Y") + 10 . '-12-31 23:59:59'; $this->aAttributes['class'] = 'form-input'; break; /* Caso email */ /* Caso email */ case 'email': $element = new ZendFormElement\Email($fieldName); $element->setLabel($this->getTranslator($fieldName) . $extraLabel); $this->aAttributes['class'] = 'form-input'; break; /* Caso number */ /* Caso number */ case 'number': $element = new ZendFormElement\Number($fieldName); $element->setLabel($this->getTranslator($fieldName) . $extraLabel); $this->aAttributes['step'] = '1'; $this->aAttributes['class'] = 'form-input'; break; case 'integer': $element = new ZendFormElement\Number($fieldName); $element->setLabel($this->getTranslator($fieldName) . $extraLabel); $this->aAttributes['min'] = '0'; $this->aAttributes['max'] = '99999999999999999999'; $this->aAttributes['step'] = '1'; $this->aAttributes['class'] = 'form-input'; break; case 'float': $element = new ZendFormElement\Number($fieldName); $element->setLabel($this->getTranslator($fieldName) . $extraLabel); $this->aAttributes['step'] = '0.001'; $this->aAttributes['class'] = 'form-input'; break; /* Plataforma */ /* Caso select */ /* Plataforma */ /* Caso select */ case 'status': $element = new ZendFormElement\Select($fieldName, array('disable_inarray_validator' => true)); $element->setLabel($this->getTranslator($fieldName) . $extraLabel); if (isset($fieldParams['placeholder']) and strtolower($fieldParams['placeholder']) == 'true') { $this->selectOptions[''] = $this->getTranslator($fieldName . '_placeholder'); } else { $this->selectOptions[''] = "---------"; } $this->aAttributes['class'] = 'form-input-select'; break; /* Caso boolean */ /* Caso boolean */ case 'boolean': $element = new ZendFormElement\Select($fieldName, array('disable_inarray_validator' => true)); $element->setLabel($this->getTranslator($fieldName) . $extraLabel); if (isset($fieldParams['placeholder']) and strtolower($fieldParams['placeholder']) == 'true') { $this->selectOptions[''] = $this->getTranslator($fieldName . '_placeholder'); } else { $this->selectOptions[''] = "---------"; } $this->aAttributes['class'] = 'form-input-select'; break; } /* Verifica se foi setado classe de estilo e implementa */ if (isset($fieldParams['class']) and !empty($fieldParams['class'])) { if (isset($this->aAttributes['class']) and $this->aAttributes['class'] != "") { $this->aAttributes['class'] = $this->aAttributes['class'] . " " . $fieldParams['class']; } else { $this->aAttributes['class'] = $fieldParams['class']; } } /* Define a descrição abaixo do campo */ if (isset($fieldParams['description']) and $fieldParams['description'] == 'true') { $this->aOptions['help-block'] = $this->getTranslator($fieldName . '_description'); } /* Verifica se foi setado grupo do campo e implementa */ if (isset($fieldParams['group']) and !empty($fieldParams['group'])) { $this->aOptions['group'] = $fieldParams['group']; } /* Verifica se foi setado placeholder no campo e implementa */ if (isset($fieldParams['placeholder']) and strtolower($fieldParams['placeholder']) == 'true') { $this->aAttributes['placeholder'] = $this->getTranslator($fieldName . '_placeholder'); } /* Verifica se foi setado somente leitura e implementa */ if (isset($fieldParams['readonly']) and strtolower($fieldParams['readonly']) == 'true') { $this->aAttributes['readonly'] = 'readonly'; } /* Verifica se foi setado desabilitado e implementa */ if (isset($fieldParams['disabled']) and strtolower($fieldParams['disabled']) == 'true') { $this->aAttributes['disabled'] = true; } /* Verifica se utilizará mascara no campo */ if (isset($fieldParams['mask']) and !empty($fieldParams['mask'])) { $this->aAttributes['data-inputmask'] = $fieldParams['mask']; } /* Verifica se foi setado inputgroup tipo append e implementa */ if (isset($fieldParams['groupappend']) and !empty($fieldParams['groupappend'])) { $this->aOptions['add-on-append'] = $fieldParams['groupappend']; } /* Verifica se foi setado inputgroup tipo prepend e implementa */ if (isset($fieldParams['groupprepend']) and !empty($fieldParams['groupprepend'])) { $this->aOptions['add-on-prepend'] = $fieldParams['groupprepend']; } /* Verifica se foi setado como array e implementa */ if (isset($fieldParams['array']) and strtolower($fieldParams['array']) == 'true') { $this->aOptions['disable_inarray_validator'] = false; } if (strtolower($fieldParams['type']) !== 'checkbox' and strtolower($fieldParams['type']) !== 'button') { if (strtolower($fieldParams['type']) !== 'textarea' and strtolower($fieldParams['type']) !== 'editor') { //$this->aOptions['column-size'] = 'col4'; } else { //$this->aOptions['column-size'] = 'col6'; } $this->aOptions['labelattributes'] = array('class' => 'form-label'); } else { //$this->aOptions['column-size'] = 'col6 col-sm-offset-2'; unset($this->aOptions['labelattributes']); } return array('element' => $element, 'params' => $fieldParams); }
public function forgottenAction() { $email = new Element\Email('email'); $email->setLabel('Registered email'); $email->setAttribute('required', 'required'); $form = new Form('password_forgotten'); $form->add($email); $emailInput = new Input(); $emailInput->getFilterChain()->attachByName('StringTrim'); $emailInput->getValidatorChain()->attachByName('EmailAddress'); $inputFilter = new InputFilter(); $inputFilter->add($emailInput); $request = $this->getRequest(); if ($request->isPost()) { $form->setData($request->getPost()); if ($form->isValid()) { $email = $form->get('email')->getValue(); //get the filtered value //Check if the email is present in the DB $entityManager = $this->getServiceLocator()->get('entity-manager'); $userEntity = $this->getServiceLocator()->get('user-entity'); $user = $entityManager->getRepository(get_class($userEntity))->findOneByEmail($email); if (!$user) { $this->flashMessenger()->addErrorMessage($this->translator->translate("The email entered is not present in our database")); return $this->redir()->toRoute('admin/default', array('controller' => 'log', 'action' => 'forgotten')); } else { //Check if the user is administrator $accessControlList = $this->getServiceLocator()->get('acl'); $allowed = $accessControlList->isAllowed($user->getRoleName(), 'index'); if (!$allowed) { $this->flashMessenger()->addErrorMessage(sprintf($this->translator->translate("The user with email %s does not have administrative privileges"), $email)); return $this->redir()->toRoute('admin/default', array('controller' => 'log', 'action' => 'forgotten')); } else { //generate token and send a link to the email $stdStrings = $this->getServiceLocator()->get('stdlib-strings'); $token = $stdStrings->randomString(10); $passwordResetsEntity = new PasswordResets($email, $token); //use this request to also delete password requests older than 24 hours $entityManager->getRepository(get_class($passwordResetsEntity))->deleteOldRequests(); $entityManager->persist($passwordResetsEntity); $entityManager->flush(); $uri = $this->getRequest()->getUri(); $renderer = $this->serviceLocator->get('Zend\\View\\Renderer\\RendererInterface'); $basePath = $renderer->basePath('/admin/log/reset'); $baseUrl = sprintf('%s://%s', $uri->getScheme(), $uri->getHost()); $link = $baseUrl . $basePath . '?email=' . urlencode($email) . '&token=' . $token; //send email with the generated password $config = $this->getServiceLocator()->get('config'); $message = new Mail\Message(); $message->setFrom($config['other']['no-reply'])->setTo($email)->setSubject('New password')->setBody(sprintf($this->translator->translate("Dear user,%sFollowing the new password request, here is a link for you to visit in order to create a new password:%s%s"), "\n\n", "\n\n", $link)); $transport = new Mail\Transport\Sendmail(); $transport->send($message); $this->flashMessenger()->addSuccessMessage(sprintf($this->translator->translate("A link was generated and sent to %s"), $email)); return $this->redir()->toRoute('admin/default', array('controller' => 'log', 'action' => 'in')); } } } } return array('form' => $form); }
public function buildForm() { $this->setAttributes(array('id' => 'post-form', 'method' => 'post')); $category = new Element\Select('category'); $category->setLabel('Categoria'); $category->setValueOptions(array_combine($this->categories, $this->categories)); $category->setAttribute('class', 'form-control'); $title = new Element\Text('title'); $title->setLabel('Título'); $title->setAttributes(array('maxlength' => 128, 'class' => 'form-control')); $description = new Element\Textarea('description'); $description->setAttribute('class', 'form-control'); $description->setLabel('Descrição'); $photoFilename = new Element\Url('photo_filename'); $photoFilename->setAttribute('class', 'form-control'); $photoFilename->setLabel('Foto'); $contactName = new Element\Text('contact_name'); $contactName->setAttribute('class', 'form-control'); $contactName->setLabel('Nome completo'); $contactEmail = new Element\Email('contact_email'); $contactEmail->setAttribute('class', 'form-control'); $contactEmail->setLabel('E-mail'); $contactPhone = new Element\Text('contact_phone'); $contactPhone->setAttribute('class', 'form-control'); $contactPhone->setLabel('Contato'); $cityCode = new Element\Select('cityCode'); $cityCode->setAttribute('class', 'form-control'); $cityCode->setValueOptions($this->cities); $cityCode->setLabel('Cidade'); $deleteCode = new Element\Number('delete_code'); $deleteCode->setAttribute('class', 'form-control'); $deleteCode->setLabel('Código de deleção'); $captcha = new Element\Captcha('captcha'); $captchaAdapter = new ImageCaptcha(array('font' => './public/fonts/arial.ttf', 'imgDir' => './public/img/captcha', 'imgUrl' => '/img/captcha')); $captchaAdapter->setWordlen(4); $captcha->setCaptcha($captchaAdapter)->setLabel('Você é um ser humano ou um robô?')->setAttribute('class', 'captchaStyle')->setAttribute('title', 'Você é um ser humano ou um robô?'); /*$captcha = new Element\Captcha('captcha'); $captcha->setCaptcha(new \Zend\Captcha\Dumb()); $captcha->setAttribute('class', 'form-control'); $captcha->setOptions(array('label' => 'Você é um ser humano ou um robô?')); */ $price = new Element\Number('price'); $price->setAttributes(array('class' => 'form-control', 'maxlength' => 12, 'min' => 0, 'max' => '999999999999')); $price->setLabel('Preço'); $dateExpires = new Element\Radio('date_expires'); $dateExpires->setLabel('Expira em (dias)'); $dateExpires->setValueOptions(array_combine($this->dateExpires, $this->dateExpires)); $csrf = new Element\Csrf('security'); $submit = new Element\Submit('submit'); $submit->setAttributes(array('class' => 'btn btn-default', 'value' => 'Enviar formulário')); $this->add($category)->add($title)->add($price)->add($dateExpires)->add($description)->add($photoFilename)->add($contactName)->add($contactEmail)->add($contactPhone)->add($cityCode)->add($deleteCode)->add($captcha)->add($csrf)->add($submit); /* $factory = new \Zend\Form\Factory(); $factory->createForm(array( 'hydrator' => 'Zend\Stdlib\Hydrator\ArraySerializable', 'elements' => array( array( 'name' => 'category', 'type' => 'text', 'options' => array( 'label' => 'Category' ) ), array( 'name' => 'title', 'type' => 'text', 'options' => array( 'label' => 'Title' ) ), ) )); */ }
<?php use Zend\Captcha; use Zend\Form\Element; use Zend\Form\Fieldset; use Zend\Form\Form; use Zend\InputFilter\Input; use Zend\InputFilter\InputFilter; $name = new Element('name'); $name->setLabel('Your name'); $name->setAttributes(array('type' => 'text')); $email = new Element\Email('email'); $email->setLabel('Your email address'); $subject = new Element('subject'); $subject->setLabel('Subject'); $subject->setAttributes(array('type' => 'text')); $message = new Element\Textarea('message'); $message->setLabel('Message'); $captcha = new Element\Captcha('captcha'); $captcha->setCaptcha(new Captcha\Dumb()); $captcha->setLabel('Please verify you are human'); $csrf = new Element\Csrf('security'); $send = new Element('send'); $send->setValue('Submit'); $send->setAttributes(array('type' => 'submit')); $form = new Form('contact'); $form->add($name); $form->add($email); $form->add($subject); $form->add($message); $form->add($captcha);
public function render($formPV, $id) { $form = new Form(); $form->setAttribute('id', $id); $inputFilter = new \Zend\InputFilter\InputFilter(); $factory = new InputFactory(); foreach ($formPV as $element) { if (isset($element->line_text)) { $attributes = $element->line_text[0]; $name = isset($attributes->name) ? $attributes->name : ''; $type = isset($attributes->type) ? $attributes->type : ''; $position = isset($attributes->order) ? $attributes->order : ''; $placeholder = isset($attributes->data->placeholder) ? $attributes->data->placeholder : ''; $label = isset($attributes->data->label) ? $attributes->data->label : ''; //$required = ($attributes->data->required == 'true') ? true : false ; $required = false; $class = isset($attributes->data->class) ? $attributes->data->class : ''; $id = isset($attributes->data->id) ? $attributes->data->id : ''; $lengthMin = isset($attributes->data->length) ? $attributes->data->length->min : ''; $lengthMax = isset($attributes->data->length) ? $attributes->data->length->max : ''; $element = new Element\Text($name); $element->setName($label); $element->setLabel($label); $element->setAttributes(array('placeholder' => $placeholder, 'required' => $required, 'class' => $class, 'id' => $id)); $form->add($element); $options = array(); $options['encoding'] = 'UTF-8'; if ($lengthMin && $lengthMin > 0) { $options['min'] = $lengthMin; } if ($lengthMax && $lengthMax > $lengthMin) { $options['max'] = $lengthMax; $element->setAttribute('maxlength', $lengthMax); $options['messages'] = array(\Zend\Validator\StringLength::TOO_LONG => sprintf($this->getServiceManager()->get('translator')->translate('This field contains more than %s characters', 'playgroundgame'), $lengthMax)); } $inputFilter->add($factory->createInput(array('name' => $name, 'required' => $required, 'filters' => array(array('name' => 'StripTags'), array('name' => 'StringTrim')), 'validators' => array(array('name' => 'StringLength', 'options' => $options))))); } if (isset($element->line_email)) { $attributes = $element->line_email[0]; $name = isset($attributes->name) ? $attributes->name : ''; $type = isset($attributes->type) ? $attributes->type : ''; $position = isset($attributes->order) ? $attributes->order : ''; $placeholder = isset($attributes->data->placeholder) ? $attributes->data->placeholder : ''; $label = isset($attributes->data->label) ? $attributes->data->label : ''; //$required = ($attributes->data->required == 'true') ? true : false ; $required = false; $class = isset($attributes->data->class) ? $attributes->data->class : ''; $id = isset($attributes->data->id) ? $attributes->data->id : ''; $lengthMin = isset($attributes->data->length) ? $attributes->data->length->min : ''; $lengthMax = isset($attributes->data->length) ? $attributes->data->length->max : ''; $element = new Element\Email($name); $element->setLabel($label); $element->setName($label); $element->setAttributes(array('placeholder' => $placeholder, 'required' => $required, 'class' => $class, 'id' => $id)); $form->add($element); $options = array(); $options['encoding'] = 'UTF-8'; if ($lengthMin && $lengthMin > 0) { $options['min'] = $lengthMin; } if ($lengthMax && $lengthMax > $lengthMin) { $options['max'] = $lengthMax; $element->setAttribute('maxlength', $lengthMax); $options['messages'] = array(\Zend\Validator\StringLength::TOO_LONG => sprintf($this->getServiceManager()->get('translator')->translate('This field contains more than %s characters', 'playgroundgame'), $lengthMax)); } $inputFilter->add($factory->createInput(array('name' => $name, 'required' => $required, 'filters' => array(array('name' => 'StripTags'), array('name' => 'StringTrim')), 'validators' => array(array('name' => 'StringLength', 'options' => $options))))); } if (isset($element->line_checkbox)) { $attributes = $element->line_checkbox[0]; $name = isset($attributes->name) ? $attributes->name : ''; $type = isset($attributes->type) ? $attributes->type : ''; $position = isset($attributes->order) ? $attributes->order : ''; $label = isset($attributes->data->label) ? $attributes->data->label : ''; // $required = ($attributes->data->required == 'yes') ? true : false; $required = false; $class = isset($attributes->data->class) ? $attributes->data->class : ''; $id = isset($attributes->data->id) ? $attributes->data->id : ''; $lengthMin = isset($attributes->data->length) ? $attributes->data->length->min : ''; $lengthMax = isset($attributes->data->length) ? $attributes->data->length->max : ''; $innerData = isset($attributes->data->innerData) ? $attributes->data->innerData : array(); $element = new Element\MultiCheckbox($name); $element->setLabel($label); $element->setName($label); $element->setAttributes(array('name' => $name, 'required' => $required, 'allowEmpty' => !$required, 'class' => $class, 'id' => $id)); $values = array(); foreach ($innerData as $value) { $values[] = $value->label; } $element->setValueOptions($values); $form->add($element); $options = array(); $options['encoding'] = 'UTF-8'; $inputFilter->add($factory->createInput(array('name' => $name, 'required' => $required, 'allowEmpty' => !$required))); } if (isset($element->line_paragraph)) { $attributes = $element->line_paragraph[0]; $name = isset($attributes->name) ? $attributes->name : ''; $type = isset($attributes->type) ? $attributes->type : ''; $position = isset($attributes->order) ? $attributes->order : ''; $placeholder = isset($attributes->data->placeholder) ? $attributes->data->placeholder : ''; $label = isset($attributes->data->label) ? $attributes->data->label : ''; $required = $attributes->data->required == 'true' ? true : false; $class = isset($attributes->data->class) ? $attributes->data->class : ''; $id = isset($attributes->data->id) ? $attributes->data->id : ''; $lengthMin = isset($attributes->data->length) ? $attributes->data->length->min : ''; $lengthMax = isset($attributes->data->length) ? $attributes->data->length->max : ''; $element = new Element\Textarea($name); $element->setName($label); $element->setLabel($label); $element->setAttributes(array('placeholder' => $placeholder, 'required' => $required, 'class' => $class, 'id' => $id)); $form->add($element); $options = array(); $options['encoding'] = 'UTF-8'; if ($lengthMin && $lengthMin > 0) { $options['min'] = $lengthMin; } if ($lengthMax && $lengthMax > $lengthMin) { $options['max'] = $lengthMax; $element->setAttribute('maxlength', $lengthMax); } $inputFilter->add($factory->createInput(array('name' => $name, 'required' => $required, 'filters' => array(array('name' => 'StripTags'), array('name' => 'StringTrim')), 'validators' => array(array('name' => 'StringLength', 'options' => $options))))); } if (isset($element->line_upload)) { $attributes = $element->line_upload[0]; //print_r($attributes); $name = isset($attributes->name) ? $attributes->name : ''; $type = isset($attributes->type) ? $attributes->type : ''; $position = isset($attributes->order) ? $attributes->order : ''; $label = isset($attributes->data->label) ? $attributes->data->label : ''; $required = $attributes->data->required == 'true' ? true : false; $class = isset($attributes->data->class) ? $attributes->data->class : ''; $id = isset($attributes->data->id) ? $attributes->data->id : ''; $filesizeMin = isset($attributes->data->filesize) ? $attributes->data->filesize->min : ''; $filesizeMax = isset($attributes->data->filesize) ? $attributes->data->filesize->max : ''; $element = new Element\File($name); $element->setLabel($label); $element->setName($label); $element->setAttributes(array('required' => $required, 'class' => $class, 'id' => $id)); $form->add($element); $inputFilter->add($factory->createInput(array('name' => $name, 'required' => $required, 'validators' => array(array('name' => '\\Zend\\Validator\\File\\Size', 'options' => array('max' => 10 * 1024 * 1024)), array('name' => '\\Zend\\Validator\\File\\Extension', 'options' => array('png,PNG,jpg,JPG,jpeg,JPEG,gif,GIF', 'messages' => array(\Zend\Validator\File\Extension::FALSE_EXTENSION => 'Veuillez télécharger une image'))))))); } if (isset($element->line_radio)) { $attributes = $element->line_radio[0]; $name = isset($attributes->name) ? $attributes->name : ''; $type = isset($attributes->type) ? $attributes->type : ''; $position = isset($attributes->order) ? $attributes->order : ''; $label = isset($attributes->data->label) ? $attributes->data->label : ''; // $required = ($attributes->data->required == 'yes') ? true : false; $required = false; $class = isset($attributes->data->class) ? $attributes->data->class : ''; $id = isset($attributes->data->id) ? $attributes->data->id : ''; $lengthMin = isset($attributes->data->length) ? $attributes->data->length->min : ''; $lengthMax = isset($attributes->data->length) ? $attributes->data->length->max : ''; $innerData = isset($attributes->data->innerData) ? $attributes->data->innerData : array(); $element = new Element\Radio($name); $element->setLabel($label); $element->setName($label); $element->setAttributes(array('name' => $name, 'required' => $required, 'allowEmpty' => !$required, 'class' => $class, 'id' => $id)); $values = array(); foreach ($innerData as $value) { $values[] = $value->label; } $element->setValueOptions($values); $form->add($element); } if (isset($element->line_dropdown)) { $attributes = $element->line_dropdown[0]; $name = isset($attributes->name) ? $attributes->name : ''; $type = isset($attributes->type) ? $attributes->type : ''; $position = isset($attributes->order) ? $attributes->order : ''; $label = isset($attributes->data->label) ? $attributes->data->label : ''; // $required = ($attributes->data->required == 'yes') ? true : false; $required = false; $class = isset($attributes->data->class) ? $attributes->data->class : ''; $id = isset($attributes->data->id) ? $attributes->data->id : ''; $lengthMin = isset($attributes->data->length) ? $attributes->data->length->min : ''; $lengthMax = isset($attributes->data->length) ? $attributes->data->length->max : ''; $dropdownValues = isset($attributes->data->dropdownValues) ? $attributes->data->dropdownValues : array(); $element = new Element\Select($name); $element->setLabel($label); $element->setName($label); $element->setAttributes(array('name' => $name, 'required' => $required, 'allowEmpty' => !$required, 'class' => $class, 'id' => $id)); $values = array(); foreach ($dropdownValues as $value) { $values[] = $value->dropdown_label; } $element->setValueOptions($values); $form->add($element); } } $form->setInputFilter($inputFilter); return $form; }