當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Forms\Helpers類代碼示例

本文整理匯總了PHP中Nette\Forms\Helpers的典型用法代碼示例。如果您正苦於以下問題:PHP Helpers類的具體用法?PHP Helpers怎麽用?PHP Helpers使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Helpers類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getControl

 /**
  * Generates control's HTML element.
  *
  * @return string
  */
 public function getControl()
 {
     $items = $this->getItems();
     reset($items);
     $input = BaseControl::getControl();
     return Helpers::createInputList($this->translate ? $this->translate($items) : $items, array_merge($input->attrs, ['id' => NULL, 'checked?' => $this->value, 'disabled:' => $this->disabled, 'required' => NULL, 'data-nette-rules:' => [key($items) => $input->attrs['data-nette-rules']]]), $this->label->attrs, $this->separator);
 }
開發者ID:webchemistry,項目名稱:forms-controls,代碼行數:12,代碼來源:CheckboxList.php

示例2: getControl

	/**
	 * Generates control's HTML element.
	 * @return Html
	 */
	public function getControl($key = NULL)
	{
		if ($key !== NULL) {
			trigger_error(sprintf('Partial %s() is deprecated; use getControlPart() instead.', __METHOD__), E_USER_DEPRECATED);
			return $this->getControlPart($key);
		}

		$input = parent::getControl();
		$ids = array();
		foreach ($this->getItems() as $value => $label) {
			$ids[$value] = $input->id . '-' . $value;
		}

		return $this->container->setHtml(
			Nette\Forms\Helpers::createInputList(
				$this->translate($this->getItems()),
				array_merge($input->attrs, array(
					'id:' => $ids,
					'checked?' => $this->value,
					'disabled:' => $this->disabled,
					'data-nette-rules:' => array(key($ids) => $input->attrs['data-nette-rules']),
				)),
				array('for:' => $ids) + $this->itemLabel->attrs,
				$this->separator
			)
		);
	}
開發者ID:nakoukal,項目名稱:fakturace,代碼行數:31,代碼來源:RadioList.php

示例3: getControl

 /**
  * Generates control's HTML element.
  * @return string
  */
 public function getControl()
 {
     $items = $this->getItems();
     reset($items);
     $input = parent::getControl();
     return Nette\Forms\Helpers::createInputList($this->translate($items), array_merge($input->attrs, array('id' => NULL, 'checked?' => $this->value, 'disabled:' => $this->disabled, 'required' => NULL, 'data-nette-rules:' => array(key($items) => $input->attrs['data-nette-rules']))), $this->label->attrs, $this->separator);
 }
開發者ID:jave007,項目名稱:test,代碼行數:11,代碼來源:CheckboxList.php

示例4: getControl

 /**
  * Generates control's HTML element.
  * @return Nette\Utils\Html
  */
 public function getControl()
 {
     $items = array();
     foreach ($this->options as $key => $value) {
         $items[is_array($value) ? $this->translate($key) : $key] = $this->translate($value);
     }
     return Nette\Forms\Helpers::createSelectBox($items, array('selected?' => $this->value, 'disabled:' => is_array($this->disabled) ? $this->disabled : NULL))->addAttributes(parent::getControl()->attrs)->multiple(TRUE);
 }
開發者ID:cujan,項目名稱:atlashornin,代碼行數:12,代碼來源:MultiSelectBox.php

示例5: getControl

 /**
  * Just remove translations from each option
  * @return Nette\Forms\Helpers
  */
 public function getControl()
 {
     $items = $this->prompt === FALSE ? array() : array('' => $this->translate($this->prompt));
     foreach ($this->options as $key => $value) {
         $items[is_array($value) ? $key : $key] = $value;
     }
     return Nette\Forms\Helpers::createSelectBox($items, array('selected?' => $this->value, 'disabled:' => is_array($this->disabled) ? $this->disabled : NULL))->addAttributes(BaseControl::getControl()->attrs);
 }
開發者ID:ublaboo,項目名稱:controls,代碼行數:12,代碼來源:NotTranslatableSelectBox.php

示例6: getControl

 /**
  * Generates control's HTML element.
  * @return Nette\Utils\Html
  */
 public function getControl()
 {
     $items = $this->prompt === FALSE ? [] : ['' => $this->translate($this->prompt)];
     foreach ($this->options as $key => $value) {
         $items[is_array($value) ? $this->translate($key) : $key] = $this->translate($value);
     }
     return Nette\Forms\Helpers::createSelectBox($items, ['selected?' => $this->value, 'disabled:' => is_array($this->disabled) ? $this->disabled : NULL])->addAttributes(parent::getControl()->attrs);
 }
開發者ID:MartinSadovy,項目名稱:forms,代碼行數:12,代碼來源:SelectBox.php

示例7: getControl

 /**
  * Generates control's HTML element.
  *
  * @return Html
  */
 public function getControl()
 {
     $items = $this->getPrompt() === FALSE ? [] : ['' => $this->translate($this->getPrompt())];
     foreach ($this->options as $key => $value) {
         $items[$this->translate && is_array($value) ? $this->translate($key) : $key] = $this->translate ? $this->translate($value) : $value;
     }
     return Helpers::createSelectBox($items, ['selected?' => $this->value, 'disabled:' => is_array($this->disabled) ? $this->disabled : NULL])->addAttributes(BaseControl::getControl()->attrs);
 }
開發者ID:webchemistry,項目名稱:forms-controls,代碼行數:13,代碼來源:SelectBox.php

示例8: getControl

 /**
  * Generates control's HTML element.
  * @return Html
  */
 public function getControl()
 {
     $items = $this->getPrompt() === FALSE ? array() : array('' => $this->translate($this->getPrompt()));
     $translated = array();
     foreach ($this->items as $key => $value) {
         $translated[$key] = $this->translate($value);
     }
     asort($translated);
     return Helpers::createSelectBox($items + $translated, array('selected?' => $this->value, 'disabled:' => is_array($this->disabled) ? $this->disabled : NULL))->addAttributes(parent::getControl()->attrs);
 }
開發者ID:pipaslot,項目名稱:forms,代碼行數:14,代碼來源:GenericSelectBox.php

示例9: getControl

 /**
  * Generates control's HTML element.
  * @return Html
  */
 public function getControl()
 {
     $input = parent::getControl();
     $items = $this->getItems();
     $ids = [];
     if ($this->generateId) {
         foreach ($items as $value => $label) {
             $ids[$value] = $input->id . '-' . $value;
         }
     }
     return $this->container->setHtml(Nette\Forms\Helpers::createInputList($this->translate($items), array_merge($input->attrs, ['id:' => $ids, 'checked?' => $this->value, 'disabled:' => $this->disabled, 'data-nette-rules:' => [key($items) => $input->attrs['data-nette-rules']]]), ['for:' => $ids] + $this->itemLabel->attrs, $this->separator));
 }
開發者ID:nette,項目名稱:forms,代碼行數:16,代碼來源:RadioList.php

示例10: getControl

 public function getControl()
 {
     $this->setOption('rendered', TRUE);
     $name = $this->getHtmlName();
     $day = Html::el('input')->type('number')->title('Den')->placeholder('den')->min(1)->max(31)->name($name . '[day]')->value($this->day);
     $month = Helpers::createSelectBox($this->months, array('selected?' => $this->month === NULL ? '' : $this->month))->name($name . '[month]')->title('Měsíc');
     $year = Html::el('input')->type('number')->min(0)->max(3000)->title('Rok')->placeholder('rok')->name($name . '[year]')->value($this->year);
     if ($this->bootstrap) {
         $day->addClass('form-control');
         $month->addClass('form-control');
         $year->addClass('form-control');
     }
     return Html::el('div')->class('date_input')->setHtml($day . $month . $year);
 }
開發者ID:zaxxx,項目名稱:zaxcms,代碼行數:14,代碼來源:Date.php

示例11: getControl

 /**
  * Generates control's HTML element.
  */
 public function getControl()
 {
     parent::getControl();
     $days = array('' => 'Den') + array_combine(range(1, 31), range(1, 31));
     $yearsRange = range(date('Y'), date('Y') - 110);
     $years = array('' => 'Rok') + array_combine($yearsRange, $yearsRange);
     $monthsCzech = \JiriNapravnik\Common\DateCzech::getCzechMonthsNominativNumericKeys();
     $months = array('' => 'Měsíc');
     for ($i = 1; $i <= 12; $i++) {
         $months[$i] = $monthsCzech[$i];
     }
     $name = $this->getHtmlName();
     return Html::el()->add(Helpers::createSelectBox($days, array('selected?' => $this->day))->name($name . '[day]')->class('form-control day'))->add(Helpers::createSelectBox($months, array('selected?' => $this->month))->name($name . '[month]')->class('form-control month'))->add(Helpers::createSelectBox($years, array('selected?' => $this->year))->name($name . '[year]')->class('form-control year'));
 }
開發者ID:jirinapravnik,項目名稱:common,代碼行數:17,代碼來源:DateInput.php

示例12: getControl

 public function getControl()
 {
     $this->setOption('rendered', TRUE);
     $name = $this->getHtmlName();
     $day = Html::el('input')->type('number')->title('Den')->placeholder('den')->min(1)->max(31)->name($name . '[day]')->value($this->day);
     $month = Helpers::createSelectBox($this->months, array('selected?' => $this->month === NULL ? '' : $this->month))->name($name . '[month]')->title('Měsíc');
     $year = Html::el('input')->type('number')->min(0)->max(3000)->title('Rok')->placeholder('rok')->name($name . '[year]')->value($this->year);
     $hour = Html::el('input')->type('number')->min(0)->max(23)->title('Hodina')->placeholder('h')->name($name . '[hour]')->value($this->hour);
     $minute = Html::el('input')->type('number')->min(0)->max(59)->title('Minuta')->placeholder('m')->name($name . '[minute]')->value($this->minute);
     if ($this->bootstrap) {
         $day->addClass('form-control');
         $month->addClass('form-control');
         $year->addClass('form-control');
         $hour->addClass('form-control');
         $minute->addClass('form-control');
         return Html::el('div')->class('row date_input')->setHtml(Html::el('div')->class('col-sm-1')->setHtml($day) . Html::el('div')->class('col-sm-2')->setHtml($month) . Html::el('div')->class('col-sm-2')->setHtml($year) . Html::el('div')->class('col-sm-1')->setHtml($hour) . Html::el('div')->class('col-sm-1')->setHtml($minute));
     } else {
         return Html::el('div')->class('date_input')->setHtml($day . $month . $year . $hour . $minute);
     }
 }
開發者ID:zaxxx,項目名稱:zaxcms,代碼行數:20,代碼來源:OldDateTime.php

示例13: getStateControlPart

 /**
  * @return Nette\Utils\Html
  */
 public function getStateControlPart()
 {
     $countryCode = $this->countryCode ?: $this->defaultCountryCode;
     $items = $this->getStates($countryCode);
     $disabled = $this->isDisabled();
     // Disabled ?
     if ($items === NULL && count($items) === 0) {
         $disabled = TRUE;
     }
     if ($items === NULL) {
         $items = array(NULL => 'without state');
     }
     /** @var Nette\Utils\Html $states */
     $states = Nette\Forms\Helpers::createSelectBox($items, array('selected?' => $this->stateCode));
     // Set attributes
     $states->addAttributes(parent::getControl()->attrs);
     $states->attrs['id'] = $this->getHtmlId() . '_states';
     $states->attrs['name'] = Nette\Forms\Helpers::generateHtmlName($this->lookupPath('Nette\\Forms\\Form') . '_states');
     if ($disabled) {
         $states->attrs['disabled'] = TRUE;
     }
     return $states;
 }
開發者ID:mike227,項目名稱:n-forms,代碼行數:26,代碼來源:CountryAndStateControl.php

示例14: getHtmlName

 /**
  * Returns HTML name of control.
  * @return string
  */
 public function getHtmlName()
 {
     return Nette\Forms\Helpers::generateHtmlName($this->lookupPath('Nette\\Forms\\Form'));
 }
開發者ID:pdostal,項目名稱:nette-blog,代碼行數:8,代碼來源:BaseControl.php

示例15: getControlPart

 /**
  * @param string $key
  *
  * @return Utils\Html
  *
  * @throws Exceptions\InvalidArgumentException
  */
 public function getControlPart($key)
 {
     $name = $this->getHtmlName();
     // Try to get translator
     $translator = $this->getTranslator();
     if ($translator instanceof Localization\ITranslator && method_exists($translator, 'getLocale') === TRUE) {
         try {
             $locale = $translator->getLocale();
         } catch (\Exception $ex) {
             $locale = 'en_US';
         }
     } else {
         $locale = 'en_US';
     }
     if ($key === static::FIELD_COUNTRY) {
         $control = Forms\Helpers::createSelectBox(array_reduce($this->getAllowedCountries(), function (array $result, $row) use($locale) {
             $countryName = FormPhone\Locale\Locale::getDisplayRegion(FormPhone\Locale\Locale::countryCodeToLocale($row), $locale);
             $result[$row] = Utils\Html::el('option')->setText('+' . $this->phoneUtils->getCountryCodeForCountry($row) . ' (' . $countryName . ')')->addAttributes(['data-mask' => preg_replace('/[0-9]/', '9', $this->phoneUtils->getExampleNationalNumber($row))])->value($row);
             return $result;
         }, []), ['selected?' => $this->country === NULL ? $this->defaultCountry : $this->country]);
         $control->addAttributes(['name' => $name . '[' . static::FIELD_COUNTRY . ']', 'id' => $this->getHtmlId() . '-' . static::FIELD_COUNTRY, 'data-ipub-forms-phone' => '', 'data-settings' => json_encode(['field' => $name . '[' . static::FIELD_NUMBER . ']'])]);
         if ($this->isDisabled()) {
             $control->disabled(TRUE);
         }
         return $control;
     } else {
         if ($key === static::FIELD_NUMBER) {
             $input = parent::getControl();
             $control = Utils\Html::el('input');
             $control->addAttributes(['name' => $name . '[' . static::FIELD_NUMBER . ']', 'id' => $this->getHtmlId() . '-' . static::FIELD_NUMBER, 'value' => $this->number, 'type' => 'text', 'data-nette-empty-value' => Utils\Strings::trim($this->translate($this->emptyValue)), 'data-nette-rules' => $input->{'data-nette-rules'}]);
             if ($this->isDisabled()) {
                 $control->disabled(TRUE);
             }
             return $control;
         }
     }
     throw new Exceptions\InvalidArgumentException('Part ' . $key . ' does not exist.');
 }
開發者ID:iPublikuj,項目名稱:form-phone,代碼行數:45,代碼來源:Phone.php


注:本文中的Nette\Forms\Helpers類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。