本文整理汇总了PHP中Phalcon\Tag::getValue方法的典型用法代码示例。如果您正苦于以下问题:PHP Tag::getValue方法的具体用法?PHP Tag::getValue怎么用?PHP Tag::getValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Phalcon\Tag
的用法示例。
在下文中一共展示了Tag::getValue方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testDisplayValues
/**
* @see 2402 issue
* @link https://github.com/phalcon/cphalcon/issues/2402
* @throws Exception
*/
public function testDisplayValues()
{
Tag::setDefault('property1', 'testVal1');
Tag::setDefault('property2', 'testVal2');
Tag::setDefault('property3', 'testVal3');
$this->assertTrue(Tag::hasValue('property1'));
$this->assertTrue(Tag::hasValue('property2'));
$this->assertTrue(Tag::hasValue('property3'));
$this->assertEquals('testVal1', Tag::getValue('property1'));
$this->assertEquals('testVal2', Tag::getValue('property2'));
$this->assertEquals('testVal3', Tag::getValue('property3'));
}
示例2: getValue
public static function getValue($name, $params = null)
{
return parent::getValue($name, $params);
}
示例3: clearFormElementsByUsingFormBind
/**
* Tests clearing the Form Elements by using Form::bind
*
* @issue 11978
* @author Serghei Iakovlev <serghei@phalconphp.com>
* @since 2016-10-01
* @param IntegrationTester $I
*/
public function clearFormElementsByUsingFormBind(IntegrationTester $I)
{
$name = new Text('sel_name');
$text = new Text('sel_text');
$form = new Form();
$form->add($name)->add($text);
$entity = new MvcModel();
$I->assertNull(Tag::getValue('sel_name'));
$I->assertNull($form->getValue('sel_name'));
$I->assertNull($form->get('sel_name')->getValue());
$I->assertNull($name->getValue());
Tag::setDefault('sel_name', 'Please specify name');
$_POST = ['sel_name' => 'Some Name', 'sel_text' => 'Some Text'];
$form->bind($_POST, $entity);
$I->assertEquals('Some Name', $entity->getName());
$I->assertEquals('Some Text', $entity->getText());
$I->assertEquals('Some Name', $form->getValue('sel_name'));
$I->assertEquals('Some Name', $form->get('sel_name')->getValue());
$I->assertEquals('Some Name', $name->getValue());
$I->assertEquals('Some Text', $form->getValue('sel_text'));
$I->assertEquals('Some Text', $form->get('sel_text')->getValue());
$I->assertEquals('Some Text', $text->getValue());
$form->clear(['sel_name']);
$I->assertNull(Tag::getValue('sel_name'));
$I->assertNull($form->getValue('sel_name'));
$I->assertNull($form->get('sel_name')->getValue());
$I->assertNull($name->getValue());
$I->assertEquals('Some Text', $form->getValue('sel_text'));
$I->assertEquals('Some Text', $form->get('sel_text')->getValue());
$I->assertEquals('Some Text', $text->getValue());
$form->clear(['non_existent', 'another_filed']);
$I->assertEquals('Some Text', $form->getValue('sel_text'));
$I->assertEquals('Some Text', $form->get('sel_text')->getValue());
$I->assertEquals('Some Text', $text->getValue());
$form->clear();
$I->assertNull(Tag::getValue('sel_text'));
$I->assertNull($form->getValue('sel_text'));
$I->assertNull($form->get('sel_text')->getValue());
$I->assertNull($text->getValue());
$I->assertEquals('Some Name', $entity->getName());
$I->assertEquals('Some Text', $entity->getText());
$I->assertEquals(['sel_name' => 'Some Name', 'sel_text' => 'Some Text'], $_POST);
}
示例4: selectField
/**
* Generates a SELECT tag
*
* @param mixed $parameters
* @param array|null $data
* @throws Exception
*/
public static function selectField($parameters, $data = null)
{
/* Type check */
if (is_null($data) === false && is_array($data) === false) {
throw new Exception('Invalid parameter type.');
}
if (is_array($parameters) === false) {
$parameters = array($parameters, $data);
}
/* Get data */
/* ID */
//@note added check for $params[id]
if (isset($parameters[0]) === false && isset($parameters['id']) === true) {
$parameters[0] = $parameters['id'];
}
$id = $parameters[0];
/* Name */
if (isset($parameters['name']) === false) {
$parameters['name'] = $id;
}
$name = $parameters['name'];
//Automatically assign the id if the name is not an array
if ($id[0] !== '[' && isset($params['id']) === false) {
$params['id'] = $id;
}
/* Value */
if (isset($params['value']) === false) {
$value = Tag::getValue($id, $parameters);
} else {
$value = $parameters['value'];
unset($parameters['value']);
}
/* Empty */
$useEmpty = false;
if (isset($parameters['useEmpty']) === true) {
/* Empty Value */
if (isset($parameters['emptyValue']) === false) {
$emptyValue = '';
} else {
$emptyValue = $parameters['emptyValue'];
unset($parameters['emptyValue']);
}
/* Empty Text */
if (isset($parameters['emptyText']) === false) {
$emptyText = 'Choose...';
} else {
$emptyText = $parameters['emptyText'];
unset($parameters['emptyText']);
}
$useEmpty = $parameters['useEmpty'];
unset($parameters['useEmpty']);
}
/* Generate Code */
$code = '<select';
if (is_array($parameters) === true) {
foreach ($parameters as $key => $avalue) {
if (is_int($key) === false) {
if (is_array($avalue) === false) {
$code .= ' ' . $key . ' = "' . htmlspecialchars($avalue) . '"';
}
}
}
}
$code .= '>' . \PHP_EOL;
if ($useEmpty === true) {
//Create an empty value
$code .= '\\t<option value="' . $emptyValue . '">' . $emptyText . '</option>' . \PHP_EOL;
}
if (isset($parameters[1]) === true) {
$options = $params[1];
} else {
$options = $data;
}
if (is_object($options) === true) {
//The options is a resultset
if (isset($parameters['using']) === false) {
throw new Exception("The 'using' parameter is required");
} else {
$using = $parameters['using'];
if (is_array($using) === false && is_object($using) === false) {
throw new Exception("The 'using' parameter should be an Array");
}
}
//Create the SELECT's option from a resultset
$code .= self::_optionsFromResultset($options, $using, $value, '</option>' . \PHP_EOL);
} else {
if (is_array($options) === true) {
//Create the SELECT's option from an array
$code .= self::_optionsFromArray($options, $value, '</option>' . \PHP_EOL);
} else {
throw new Exception('Invalid data provided to SELECT helper');
}
}
//.........这里部分代码省略.........