本文整理汇总了PHP中Nette\Forms\Controls\BaseControl::isRequired方法的典型用法代码示例。如果您正苦于以下问题:PHP BaseControl::isRequired方法的具体用法?PHP BaseControl::isRequired怎么用?PHP BaseControl::isRequired使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Forms\Controls\BaseControl
的用法示例。
在下文中一共展示了BaseControl::isRequired方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: label
public static function label(Html $label, BaseControl $control, $isPart)
{
if ($label->getName() === 'label') {
$label->addClass('control-label');
}
if ($control->isRequired()) {
$label->addClass('required');
}
return $label;
}
示例2: prepareControl
/**
* @param \Nette\Forms\Controls\BaseControl $control
*/
private function prepareControl(Controls\BaseControl $control)
{
$translator = $this->form->getTranslator();
$control->setOption('rendered', FALSE);
if ($control->isRequired()) {
$control->getLabelPrototype()->addClass('required');
$control->setOption('required', TRUE);
}
$el = $control->getControlPrototype();
if ($placeholder = $control->getOption('placeholder')) {
if (!$placeholder instanceof Html && $translator) {
$placeholder = $translator->translate($placeholder);
}
$el->placeholder($placeholder);
}
if ($control->controlPrototype->type === 'email' && $control->getOption('input-prepend') === NULL) {
$control->setOption('input-prepend', Html::el('i class="fa fa-fw fa-envelope"'));
}
if ($control->controlPrototype->type === 'password' && $control->getOption('input-prepend') === NULL) {
$control->setOption('input-prepend', Html::el('i class="fa fa-fw fa-lock"'));
}
if ($control instanceof \Nette\Forms\ISubmitterControl) {
$el->addClass('btn');
} else {
$control->setOption('pairContainer', $pair = Html::el('div'));
$pair->id = $control->htmlId . '-pair';
$pair->addClass('form-group');
$label = $control->labelPrototype;
if (static::isCheckbox($control)) {
$label->addClass('checkbox');
} elseif (!$control instanceof Controls\RadioList && !self::isCheckboxList($control)) {
$label->addClass('control-label');
if (!$control instanceof \Minetro\Forms\reCAPTCHA\ReCaptchaField) {
$el->addClass('form-control');
}
}
if ($control->getOption('required', FALSE)) {
$pair->addClass('required');
}
if ($control->errors) {
$pair->addClass('has-error');
}
if ($prepend = $control->getOption('input-prepend')) {
$prepend = Html::el('span', array('class' => 'input-group-addon'))->{$prepend instanceof Html ? 'add' : 'setText'}($prepend);
$control->setOption('input-prepend', $prepend);
}
if ($append = $control->getOption('input-append')) {
$append = Html::el('span', array('class' => 'input-group-addon'))->{$append instanceof Html ? 'add' : 'setText'}($append);
$control->setOption('input-append', $append);
}
}
}
示例3: prepareControl
/**
* @param \Nette\Forms\Controls\BaseControl $control
*/
private function prepareControl(Controls\BaseControl $control)
{
$translator = $this->form->getTranslator();
$control->setOption('rendered', FALSE);
if ($control->isRequired()) {
$control->getLabelPrototype()->addClass('required');
$control->setOption('required', TRUE);
}
$el = $control->getControlPrototype();
if ($placeholder = $control->getOption('placeholder')) {
if (!$placeholder instanceof Html && $translator) {
$placeholder = $translator->translate($placeholder);
}
$el->placeholder($placeholder);
}
if ($control->controlPrototype->type === 'email' && $control->getOption('input-prepend') === NULL) {
$control->setOption('input-prepend', '@');
}
if ($control instanceof Nette\Forms\ISubmitterControl) {
$el->addClass('btn');
} else {
$label = $control->labelPrototype;
if ($control instanceof Controls\Checkbox) {
$label->addClass('checkbox');
} elseif (!$control instanceof Controls\RadioList && !self::isCheckboxList($control)) {
$label->addClass('control-label');
}
$control->setOption('pairContainer', $pair = Html::el('div'));
$pair->id = $control->htmlId . '-pair';
$pair->addClass('control-group');
if ($control->getOption('required', FALSE)) {
$pair->addClass('required');
}
if ($control->errors) {
$pair->addClass('error');
}
if ($prepend = $control->getOption('input-prepend')) {
$prepend = Html::el('span', array('class' => 'add-on'))->{$prepend instanceof Html ? 'add' : 'setText'}($prepend);
$control->setOption('input-prepend', $prepend);
}
if ($append = $control->getOption('input-append')) {
$append = Html::el('span', array('class' => 'add-on'))->{$append instanceof Html ? 'add' : 'setText'}($append);
$control->setOption('input-append', $append);
}
}
}
示例4: isRequired
/**
* {@inheritdoc}
*/
public function isRequired()
{
return $this->wrappedControl->isRequired();
}
示例5: prepareControl
/**
* @param \Nette\Forms\Controls\BaseControl $control
*/
private function prepareControl(Controls\BaseControl $control)
{
$translator = $this->form->getTranslator();
$control->setOption('rendered', FALSE);
if ($control->isRequired()) {
$control->getLabelPrototype()->addClass('required');
$control->setOption('required', TRUE);
}
$el = $control->getControlPrototype();
if ($placeholder = $control->getOption('placeholder')) {
if (!$placeholder instanceof Html && $translator) {
$placeholder = $translator->translate($placeholder);
}
$el->placeholder($placeholder);
}
if ($control->controlPrototype->type === 'email' && $control->getOption('input-prepend') === NULL) {
$control->setOption('input-prepend', '@');
}
if ($control instanceof Nette\Forms\ISubmitterControl) {
$el->addClass('btn');
if ($control->getOption('btn-class') !== NULL) {
$el->addClass($control->getOption('btn-class'));
} else {
$el->addClass('btn-default');
}
} else {
if (static::isTextBase($control) || $control instanceof Controls\SelectBox) {
$classes = $control->controlPrototype->class;
if (!is_array($classes)) {
$classes = explode(' ', $classes);
}
if (($pos = array_search('no-form-control', $classes, TRUE)) !== FALSE) {
unset($classes[$pos]);
$el->class = $classes;
} elseif ($control->getOption('noFormControl', FALSE) !== TRUE) {
$el->addClass('form-control');
}
}
$label = $control->labelPrototype;
if (!$control instanceof Controls\Checkbox && !$control instanceof Controls\RadioList && !static::isCheckboxList($control)) {
$label->addClass('control-label');
}
$control->setOption('pairContainer', $pair = Html::el('div'));
$pair->id = $control->htmlId . '-pair';
$pair->addClass('form-group');
if ($control->getOption('required', FALSE)) {
$pair->addClass('required');
}
if ($control->errors) {
$pair->addClass('has-error');
}
}
}
示例6: prepareControl
/**
* @param \Nette\Forms\Controls\BaseControl $control
*/
private function prepareControl(Controls\BaseControl $control)
{
$translator = $this->form->getTranslator();
$control->setOption('rendered', FALSE);
if ($control->isRequired()) {
$control->getLabelPrototype()->addClass('required');
}
$el = $control->getControlPrototype();
if ($el->getName() === 'input') {
$el->class(strtr($el->type, array('password' => 'text', 'file' => 'text', 'submit' => 'button', 'image' => 'imagebutton')), TRUE);
}
if ($placeholder = $control->getOption('placeholder')) {
if (!$placeholder instanceof Html && $translator) {
$placeholder = $translator->translate($placeholder);
}
$el->placeholder($placeholder);
}
if ($control->controlPrototype->type === 'email') {
$email = Html::el('span', array('class' => 'add-on'))->setText('@');
$control->setOption('input-prepend', $email);
}
if ($control instanceof Nette\Forms\ISubmitterControl) {
$el->addClass('btn');
}
}