本文整理汇总了PHP中Nette\Forms\Controls\BaseControl::getControlPrototype方法的典型用法代码示例。如果您正苦于以下问题:PHP BaseControl::getControlPrototype方法的具体用法?PHP BaseControl::getControlPrototype怎么用?PHP BaseControl::getControlPrototype使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Forms\Controls\BaseControl
的用法示例。
在下文中一共展示了BaseControl::getControlPrototype方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createButton
public function createButton()
{
if ($this->button) {
return FALSE;
}
/** @var Nette\Forms\Container $container */
$container = $this->control->lookup('Nette\\Forms\\Container');
$name = $this->control->getName() . self::$buttonSuffix;
$this->button = new SubmitButton("Apply");
$this->button->setValidationScope(false);
$container->addComponent($this->button, $name);
$this->control->getControlPrototype()->addAttributes(array('data-apply-button' => $this->button->getHtmlId()));
return TRUE;
}
示例2: updateControlClass
/**
* Update html class of control
*/
protected function updateControlClass()
{
if ($this->controlClass !== null) {
$classes = explode(" ", $this->control->getControlPrototype()->class);
if (!in_array($this->controlClass, $classes)) {
$this->control->getControlPrototype()->class($this->controlClass);
}
}
}
示例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', 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);
}
}
}
示例4: 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);
}
}
}
示例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: addClientSideRule
/**
* @param BaseControl $control
* @param string $rule
* @param string $message
* @param mixed $arg
*/
protected function addClientSideRule(BaseControl $control, $rule, $message, $arg = NULL)
{
$constraint = array('op' => lcfirst($rule), 'msg' => $message);
if (!empty($arg)) {
$constraint['arg'] = $arg;
}
$controlPrototype = $control->getControlPrototype();
$attr = $this->clientSideRulesAttribute;
if (is_array($controlPrototype->{$attr})) {
$controlPrototype->{$attr} = array_merge($controlPrototype->{$attr}, array($constraint));
} else {
$controlPrototype->{$attr} = array($constraint);
}
}
示例7: 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');
}
}