Ejemplo n.º 1
0
 /**
  * {@inheritDoc}
  */
 public function form(PhpRenderer $view, array $options = [])
 {
     $urlInput = new UrlElement('o:media[__index__][o:source]');
     $urlInput->setOptions(['label' => $view->translate('oEmbed URL'), 'info' => $view->translate('URL for the media to embed.')]);
     $urlInput->setAttributes(['id' => 'media-oembed-source-__index__', 'required' => true]);
     return $view->formRow($urlInput);
 }
 public function getForm(array $companyTypes, array $statusList)
 {
     if (!$this->form) {
         $companyId = new Element\Hidden();
         $companyId->setName('companyId');
         $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');
         $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');
         $type = new Element\Select();
         $type->setName("type")->setLabel('Type')->setAttribute('class', 'form-control')->setValueOptions($companyTypes);
         $status = new Element\Select();
         $status->setName("status")->setLabel('Status')->setAttribute('class', 'form-control')->setValueOptions($statusList);
         $form = new Form();
         $form->setAttribute('class', 'form-horizontal');
         $form->add($companyId);
         $form->add($name);
         $form->add($phone);
         $form->add($address);
         $form->add($website);
         $form->add($type);
         $form->add($status);
         $this->form = $form;
     }
     return $this->form;
 }
Ejemplo n.º 3
0
 /**
  * {@inheritDoc}
  */
 public function form(PhpRenderer $view, array $options = [])
 {
     $urlInput = new UrlElement('o:media[__index__][ingest_url]');
     $urlInput->setOptions(['label' => $view->translate('URL'), 'info' => $view->translate('A URL to the media.')]);
     $urlInput->setAttributes(['id' => 'media-url-ingest-url-__index__', 'required' => true]);
     return $view->formRow($urlInput);
 }
Ejemplo n.º 4
0
 /**
  * {@inheritDoc}
  */
 public function form(PhpRenderer $view, array $options = [])
 {
     $urlInput = new UrlElement('o:media[__index__][o:source]');
     $urlInput->setOptions(['label' => $view->translate('Video URL'), 'info' => $view->translate('URL for the video to embed.')]);
     $urlInput->setAttributes(['id' => 'media-youtube-source-__index__', 'required' => true]);
     $urlInput->setAttributes(['id' => 'media-youtube-source-__index__', 'required' => true]);
     $startInput = new Text('o:media[__index__][start]');
     $startInput->setOptions(['label' => $view->translate('Start'), 'info' => $view->translate('Begin playing the video at the given number of seconds from the start of the video.')]);
     $endInput = new Text('o:media[__index__][end]');
     $endInput->setOptions(['label' => $view->translate('End'), 'info' => $view->translate('End playing the video at the given number of seconds from the start of the video.')]);
     return $view->formRow($urlInput) . $view->formRow($startInput) . $view->formRow($endInput);
 }
 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);
 }
Ejemplo n.º 6
0
 public function __construct($name = null)
 {
     parent::__construct('links');
     $weight_hidden = new Element\Hidden('weight');
     $title_text = new Element\Text('name');
     $title_text->setLabel('Title');
     $title_text->setLabelAttributes(array('class' => 'type_text'));
     $title_text->setAttributes(array('class' => 'type_text_input', 'placeholder' => 'Type something...', 'required' => true));
     $url_text = new Element\Url('ref');
     $url_text->setLabel('Url');
     $url_text->setLabelAttributes(array('class' => 'type_text'));
     $url_text->setAttributes(array('class' => 'type_text_input', 'placeholder' => 'Type something...', 'required' => true));
     $description_textarea = new Element\Textarea('description');
     $description_textarea->setLabel('Description');
     $description_textarea->setLabelAttributes(array('class' => 'type_text'));
     $description_textarea->setAttributes(array('class' => 'type_text_input', 'placeholder' => 'Type something...'));
     $this->add($weight_hidden);
     $this->add($title_text);
     $this->add($url_text);
     $this->add($description_textarea);
 }
Ejemplo n.º 7
0
 public function testProvidesInputSpecificationThatIncludesValidatorsBasedOnAttributes()
 {
     $element = new UrlElement();
     $element->setAttributes(array('allowAbsolute' => true, 'allowRelative' => false));
     $inputSpec = $element->getInputSpecification();
     $this->assertArrayHasKey('validators', $inputSpec);
     $this->assertInternalType('array', $inputSpec['validators']);
     $expectedClasses = array('Zend\\Validator\\Uri');
     foreach ($inputSpec['validators'] as $validator) {
         $class = get_class($validator);
         $this->assertTrue(in_array($class, $expectedClasses), $class);
         switch ($class) {
             case 'Zend\\Validator\\Uri':
                 $this->assertEquals(true, $validator->getAllowAbsolute());
                 $this->assertEquals(false, $validator->getAllowRelative());
                 break;
             default:
                 break;
         }
     }
 }
 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;
 }
Ejemplo n.º 9
0
 public function __construct($name = null)
 {
     parent::__construct($name);
     $this->add(new Element\Hidden('latitude'));
     $this->add(new Element\Hidden('longitude'));
     $bool_apt = new Element\Radio('bool_apt');
     $bool_apt->setLabel('Is POBox?')->setLabelAttributes(array('class' => 'radio-inline'))->setValueOptions(array('1' => 'No', '0' => 'Yes'))->setAttributes(array('class' => 'medwhite'));
     $this->add($bool_apt);
     $apt_or_pobox = new Element\Text('apt_or_pobox');
     $apt_or_pobox->setLabel('Apartment No. or PO Box')->setAttributes(array('class' => 'form-control input-sm'));
     $this->add($apt_or_pobox);
     $street_line1 = new Element\Text('street_line1');
     $street_line1->setLabel('Street Line 1')->setAttributes(array('class' => 'form-control input-sm'));
     $this->add($street_line1);
     $street_line2 = new Element\Text('street_line2');
     $street_line2->setLabel('Street Line 2')->setAttributes(array('class' => 'form-control input-sm'));
     $this->add($street_line2);
     $city = new Element\Text('city');
     $city->setLabel('City')->setAttributes(array('class' => 'form-control input-sm'));
     $this->add($city);
     $state_or_province = new Element\Select('state_or_province');
     $state_or_province->setLabel('State or Province')->setAttributes(array('class' => 'form-control input-sm'));
     $this->add($state_or_province);
     $country = new Element\Select('country');
     $country->setLabel('Country')->setAttributes(array('class' => 'form-control input-sm'))->setValueOptions(array('' => 'Select a country'));
     $this->add($country);
     $zipcode = new Element\Text('zipcode');
     $zipcode->setLabel('Zip Code')->setAttributes(array('class' => 'form-control input-sm'));
     $this->add($zipcode);
     $url_map = new Element\Url('url_map');
     $url_map->setLabel('Map Url')->setAttributes(array('class' => 'form-control input-sm'));
     $this->add($url_map);
     $comment = new Element\Textarea('comment');
     $comment->setLabel('Comment')->setAttributes(array('class' => 'form-control input-sm'));
     $this->add($comment);
 }
Ejemplo n.º 10
0
 /**
  * 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">&nbsp;</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;
 }
Ejemplo n.º 11
0
 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);
 }
Ejemplo n.º 12
0
 public function form(PhpRenderer $view, array $options = [])
 {
     $urlInput = new UrlElement('o:media[__index__][o:source]');
     $urlInput->setOptions(['label' => $view->translate('IIIF Image URL'), 'info' => $view->translate('URL for the image to embed.')]);
     return $view->formRow($urlInput);
 }
Ejemplo n.º 13
0
 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);
 }
Ejemplo n.º 14
0
 public function __construct()
 {
     parent::__construct('online');
     $this->setHydrator(new ArraySerializableHydrator(false));
     $adress_text = new Element\Url('url');
     $adress_text->setLabel('Url');
     $adress_text->setLabelAttributes(array('class' => 'type_text'));
     $adress_text->setAttributes(array('class' => 'type_text_input', 'placeholder' => 'Type adress in format', 'required' => true));
     $this->add($adress_text);
     $this->add(array('type' => 'Button', 'name' => 'submit', 'options' => array('label' => 'delete'), 'attributes' => array('class' => 'btn btn btn_red3')));
 }
Ejemplo n.º 15
0
 /**
  * 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);
 }
Ejemplo n.º 16
0
 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'
                         )
                     ),
                 )
             )); */
 }
Ejemplo n.º 17
0
 /**
  * {@inheritDoc}
  */
 public function getInputSpecification()
 {
     $spec = parent::getInputSpecification();
     $spec['required'] = false;
     return $spec;
 }