/** * Load upload editor * * @return mixed */ public function load() { $property = $this->getProperty(); $value = @unserialize($this->getValue()); $originalUrl = !empty($value[0]) ? $value[0] : ''; $tinyUrl = !empty($value[1]) ? $value[1] : ''; $textstring = new Element\Url($this->getName()); $textstring->setAttribute('class', 'form-control'); $textstring->setAttribute('id', $this->getName()); $textstring->setLabel($property->getName()); $textstring->setValue($originalUrl); $textstring->setAttribute('required', $property->isRequired()); $data = array($textstring); if (!empty($tinyUrl)) { $html = '<div class="col-lg-2"> </div><div class="col-lg-10 bg-warning">'; $html .= sprintf('<a href="%s" target="_blank" class="btn btn-link">', $tinyUrl); $html .= $tinyUrl; $html .= '</a></div>'; $data[] = $html; } return $data; }
public function __construct(EntityRepository $repository) { parent::__construct('signup'); $this->filter = new InputFilter(); $email = new Element\Email('email'); $email->setAttribute('required', true); $email->setAttribute('placeholder', 'Email Address'); $this->add($email); $emailFilter = new Input('email'); $emailFilter->setRequired(true); $emailFilter->getValidatorChain()->attach(new DoctrineValidator\NoObjectExists(array('message' => 'Email address already in use', 'object_repository' => $repository, 'fields' => 'email'))); $this->filter->add($emailFilter); $password = new Element\Password('password'); $password->setAttribute('required', true); $password->setAttribute('placeholder', 'Password'); $this->add($password); $passwordFilter = new Input('password'); $passwordFilter->setRequired(true); $passwordFilter->getFilterChain()->attach(new Filter\StringTrim()); $passwordFilter->getValidatorChain()->attach(new AppValidator\PasswordStrength()); $this->filter->add($passwordFilter); $confirmPassword = new Element\Password('confirmPassword'); $confirmPassword->setAttribute('required', true); $confirmPassword->setAttribute('placeholder', 'Confirm Password'); $this->add($confirmPassword); $confirmPasswordFilter = new Input('confirmPassword'); $confirmPasswordFilter->setRequired(true); $confirmPasswordFilter->getFilterChain()->attach(new Filter\StringTrim()); $confirmPasswordFilter->getValidatorChain()->attach(new Validator\Identical('password')); $this->filter->add($confirmPasswordFilter); $firstName = new Element\Text('firstName'); $firstName->setAttribute('required', true); $firstName->setAttribute('placeholder', 'First Name'); $this->add($firstName); $firstNameFilter = new Input('firstName'); $firstNameFilter->setRequired(true); $firstNameFilter->getFilterChain()->attach(new AppFilter\TitleCase()); $firstNameFilter->getFilterChain()->attach(new Filter\StringTrim()); $firstNameFilter->getFilterChain()->attach(new Filter\StripTags()); $firstNameFilter->getValidatorChain()->attach(new Validator\StringLength(array('max' => 35))); $firstNameFilter->getValidatorChain()->attach(new LocaleValidator\Alpha(array('allowWhiteSpace' => true))); $this->filter->add($firstNameFilter); $lastName = new Element\Text('lastName'); $lastName->setAttribute('required', true); $lastName->setAttribute('placeholder', 'Last Name'); $this->add($lastName); $lastNameFilter = new Input('lastName'); $lastNameFilter->setRequired(true); $lastNameFilter->getFilterChain()->attach(new AppFilter\TitleCase()); $lastNameFilter->getFilterChain()->attach(new Filter\StringTrim()); $lastNameFilter->getFilterChain()->attach(new Filter\StripTags()); $lastNameFilter->getValidatorChain()->attach(new Validator\StringLength(array('max' => 35))); $lastNameFilter->getValidatorChain()->attach(new LocaleValidator\Alpha(array('allowWhiteSpace' => true))); $this->filter->add($lastNameFilter); $street = new Element\Text('street'); $street->setAttribute('required', true); $street->setAttribute('placeholder', 'Street Address'); $this->add($street); $streetFilter = new Input('street'); $streetFilter->setRequired(true); $streetFilter->getFilterChain()->attach(new Filter\StringTrim()); $streetFilter->getFilterChain()->attach(new Filter\StripTags()); $streetFilter->getValidatorChain()->attach(new Validator\StringLength(array('max' => 50))); $this->filter->add($streetFilter); $city = new Element\Text('city'); $city->setAttribute('required', true); $city->setAttribute('placeholder', 'City'); $this->add($city); $cityFilter = new Input('city'); $cityFilter->setRequired(true); $cityFilter->getFilterChain()->attach(new Filter\StringTrim()); $cityFilter->getFilterChain()->attach(new Filter\StripTags()); $cityFilter->getValidatorChain()->attach(new Validator\StringLength(array('max' => 30))); $this->filter->add($cityFilter); $state = new Element\Text('state'); $state->setAttribute('required', true); $state->setAttribute('placeholder', 'State'); $this->add($state); $stateFilter = new Input('state'); $stateFilter->setRequired(true); $stateFilter->getFilterChain()->attach(new Filter\StringTrim()); $stateFilter->getFilterChain()->attach(new Filter\StripTags()); $stateFilter->getFilterChain()->attach(new Filter\StringToUpper()); $stateFilter->getValidatorChain()->attach(new Validator\StringLength(array('min' => 2, 'max' => 2))); $this->filter->add($stateFilter); $postalCode = new Element\Text('postalCode'); $postalCode->setAttribute('required', true); $postalCode->setAttribute('placeholder', 'Postal Code'); $this->add($postalCode); $postalCodeFilter = new Input('postalCode'); $postalCodeFilter->setRequired(true); $postalCodeFilter->getFilterChain()->attach(new Filter\StringTrim()); $postalCodeFilter->getFilterChain()->attach(new Filter\StripTags()); $this->filter->add($postalCodeFilter); $phone = new AppElement\Phone('phone'); $phone->setAttribute('required', true); $phone->setAttribute('placeholder', 'Phone Number'); $this->add($phone); $phoneFilter = new Input('phone'); $phoneFilter->setRequired(true); $this->filter->add($phoneFilter); $website = new Element\Url('website'); $website->setAttribute('placeholder', 'Website'); $this->add($website); $websiteFilter = new Input('website'); $websiteFilter->setRequired(false); $this->filter->add($websiteFilter); $submit = new Element\Submit('submit'); $submit->setAttribute('class', 'btn-primary pull-right'); $submit->setOption('glyphicon', 'user'); $submit->setLabel('Sign Up'); $this->add($submit); }
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' ) ), ) )); */ }
public function __construct(EntityRepository $repository) { parent::__construct('apply'); $this->filter = new InputFilter(); $primary = new Element\Hidden('primary'); $this->add($primary); $primaryFilter = new Input('primary'); $primaryFilter->getValidatorChain()->attach(new DoctrineValidator\NoObjectExists(array('message' => 'Member already owns an affiliate', 'object_repository' => $repository, 'fields' => 'primary'))); $this->filter->add($primaryFilter); $name = new Element\Text('name'); $name->setAttribute('required', true); $name->setAttribute('placeholder', 'Organization Name'); $this->add($name); $nameFilter = new Input('name'); $nameFilter->setRequired(true); $nameFilter->getFilterChain()->attach(new AppFilter\TitleCase()); $nameFilter->getFilterChain()->attach(new Filter\StringTrim()); $nameFilter->getFilterChain()->attach(new Filter\StripTags()); $nameFilter->getValidatorChain()->attach(new Validator\StringLength(array('max' => 80))); $nameFilter->getValidatorChain()->attach(new DoctrineValidator\NoObjectExists(array('message' => 'Name already in use', 'object_repository' => $repository, 'fields' => 'name'))); $this->filter->add($nameFilter); $street = new Element\Text('street'); $street->setAttribute('required', true); $street->setAttribute('placeholder', 'Street Address'); $this->add($street); $streetFilter = new Input('street'); $streetFilter->setRequired(true); $streetFilter->getFilterChain()->attach(new Filter\StringTrim()); $streetFilter->getFilterChain()->attach(new Filter\StripTags()); $streetFilter->getValidatorChain()->attach(new Validator\StringLength(array('max' => 50))); $this->filter->add($streetFilter); $city = new Element\Text('city'); $city->setAttribute('required', true); $city->setAttribute('placeholder', 'City'); $this->add($city); $cityFilter = new Input('city'); $cityFilter->setRequired(true); $cityFilter->getFilterChain()->attach(new Filter\StringTrim()); $cityFilter->getFilterChain()->attach(new Filter\StripTags()); $cityFilter->getValidatorChain()->attach(new Validator\StringLength(array('max' => 30))); $this->filter->add($cityFilter); $state = new Element\Text('state'); $state->setAttribute('required', true); $state->setAttribute('placeholder', 'State'); $this->add($state); $stateFilter = new Input('state'); $stateFilter->setRequired(true); $stateFilter->getFilterChain()->attach(new Filter\StringTrim()); $stateFilter->getFilterChain()->attach(new Filter\StripTags()); $stateFilter->getFilterChain()->attach(new Filter\StringToUpper()); $stateFilter->getValidatorChain()->attach(new Validator\StringLength(array('min' => 2, 'max' => 2))); $this->filter->add($stateFilter); $postalCode = new Element\Text('postalCode'); $postalCode->setAttribute('required', true); $postalCode->setAttribute('placeholder', 'Postal Code'); $this->add($postalCode); $postalCodeFilter = new Input('postalCode'); $postalCodeFilter->setRequired(true); $postalCodeFilter->getFilterChain()->attach(new Filter\StringTrim()); $postalCodeFilter->getFilterChain()->attach(new Filter\StripTags()); $this->filter->add($postalCodeFilter); $phone = new AppElement\Phone('phone'); $phone->setAttribute('required', true); $phone->setAttribute('placeholder', 'Phone Number'); $this->add($phone); $phoneFilter = new Input('phone'); $phoneFilter->setRequired(true); $this->filter->add($phoneFilter); $email = new Element\Email('email'); $email->setAttribute('required', true); $email->setAttribute('placeholder', 'Email Address'); $this->add($email); $emailFilter = new Input('email'); $emailFilter->setRequired(true); $this->filter->add($emailFilter); $website = new Element\Url('website'); $website->setAttribute('placeholder', 'Website'); $this->add($website); $websiteFilter = new Input('website'); $websiteFilter->setRequired(false); $this->filter->add($websiteFilter); $buttons = new Form('buttons'); $buttons->setOption('twb-layout', 'inline'); $buttons->setAttribute('class', 'form-group'); $submit = new Element\Submit('submit'); $submit->setAttribute('class', 'btn-primary pull-right'); $submit->setOption('glyphicon', 'circle-arrow-up'); $submit->setLabel('Apply'); $buttons->add($submit); $cancel = new Element\Submit('cancel'); $cancel->setAttribute('formnovalidate', true); $cancel->setAttribute('class', 'btn-warning pull-right'); $cancel->setOption('glyphicon', 'ban-circle'); $cancel->setLabel('Cancel'); $buttons->add($cancel); $this->add($buttons); }