本文整理汇总了PHP中Tag::setAttributes方法的典型用法代码示例。如果您正苦于以下问题:PHP Tag::setAttributes方法的具体用法?PHP Tag::setAttributes怎么用?PHP Tag::setAttributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tag
的用法示例。
在下文中一共展示了Tag::setAttributes方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setProgress
/**
* @param bool|int $progress
*/
public function setProgress($progress)
{
$this->progress = $progress;
if ($progress !== false) {
$this->bar->setAttributes(['style' => 'width: ' . $this->progress . '%;']);
$this->setAttributes(['aria-valuenow' => $this->progress]);
} else {
$this->removeAttributes(['aria-valuenow']);
}
$this->toggleClasses(['oo-ui-progressBarWidget-indeterminate'], $progress === false);
}
示例2: setAccessKey
/**
* Set access key.
*
* @param string $accessKey Tag's access key, use empty string to remove
* @return $this
*/
public function setAccessKey($accessKey)
{
$accessKey = is_string($accessKey) && strlen($accessKey) ? $accessKey : null;
if ($this->accessKey !== $accessKey) {
if ($accessKey !== null) {
$this->accessKeyed->setAttributes(['accesskey' => $accessKey]);
} else {
$this->accessKeyed->removeAttributes(['accesskey']);
}
$this->accessKey = $accessKey;
}
return $this;
}
示例3: getInputElement
protected function getInputElement($config)
{
$type = in_array($config['type'], array('button', 'submit', 'reset')) ? $config['type'] : 'button';
$input = new Tag($config['useInputTag'] ? 'input' : 'button');
$input->setAttributes(array('type' => $type));
return $input;
}
示例4: setOptions
/**
* Set the options available for this input.
*
* @param array[] $options Array of menu options in the format
* `array( 'data' => …, 'label' => … )`
* @chainable
*/
public function setOptions($options)
{
$value = $this->getValue();
$isValueAvailable = false;
$this->options = array();
// Rebuild the dropdown menu
$this->input->clearContent();
foreach ($options as $opt) {
$optValue = $this->cleanUpValue($opt['data']);
$option = new Tag('option');
$option->setAttributes(array('value' => $optValue));
$option->appendContent(isset($opt['label']) ? $opt['label'] : $optValue);
if ($value === $optValue) {
$isValueAvailable = true;
}
$this->options[] = $option;
$this->input->appendContent($option);
}
// Restore the previous value, or reset to something sensible
if ($isValueAvailable) {
// Previous value is still available
$this->setValue($value);
} else {
// No longer valid, reset
if (count($options)) {
$this->setValue($options[0]['data']);
}
}
return $this;
}
示例5: _test_should_store_zero_strings_as_intergers
public function _test_should_store_zero_strings_as_intergers()
{
$Tag = new Tag(array('name' => 'Ticket #21'));
$this->assertTrue($Tag->save());
$this->assertEqual($Tag->get('score'), 100);
$Tag->setAttributes(array('score' => '0'));
$this->assertTrue($Tag->save());
$Tag = $Tag->find($Tag->id);
$this->assertIdentical($Tag->get('score'), 0);
}
示例6: testCreate
public function testCreate()
{
$tag = new Tag();
$tag->setAttributes(array('name' => 'Apple', 'category' => 1));
$this->assertTrue($tag->save());
$tag2 = Tag::model()->findByPk($tag->id);
$this->assertNotNull($tag2);
$this->assertEquals($tag->name, $tag2->name);
$this->assertEquals($tag->category, $tag2->category);
$this->assertEquals(1, $tag2->frequency);
$this->assertTrue(time() - $tag2->create_time <= 1);
}
示例7: setDisabled
public function setDisabled($state)
{
parent::setDisabled($state);
if (isset($this->input)) {
if ($this->isDisabled()) {
$this->input->setAttributes(['disabled' => 'disabled']);
} else {
$this->input->removeAttributes(['disabled']);
}
}
return $this;
}
示例8: initializeButtonElement
/**
* @param array $config Configuration options
* @param boolean $config['framed'] Render button with a frame (default: true)
*/
public function initializeButtonElement(array $config = [])
{
// Properties
if (!$this instanceof Element) {
throw new Exception("ButtonElement trait can only be used on Element instances");
}
$target = isset($config['button']) ? $config['button'] : new Tag('a');
$this->button = $target;
// Initialization
$this->addClasses(['oo-ui-buttonElement']);
$this->button->addClasses(['oo-ui-buttonElement-button']);
$this->toggleFramed(isset($config['framed']) ? $config['framed'] : true);
// Add `role="button"` on `<a>` elements, where it's needed
if (strtolower($this->button->getTag()) === 'a') {
$this->button->setAttributes(['role' => 'button']);
}
$this->registerConfigCallback(function (&$config) {
if ($this->framed !== true) {
$config['framed'] = $this->framed;
}
});
}
示例9: testAttributes
public function testAttributes()
{
$tag = new Tag('a');
$this->assertNull($tag->getAttribute('href'));
$this->assertNull($tag->href);
$tag->href = "#";
$this->assertSame('#', $tag->href);
$this->assertSame('#', $tag->getAttribute('href'));
$this->assertSame(array('href' => '#'), $tag->getAttributes());
$tag->setAttribute('href', 'javascript:void(0)');
$this->assertSame('javascript:void(0)', $tag->href);
$this->assertSame('javascript:void(0)', $tag->getAttribute('href'));
$this->assertSame(array('href' => 'javascript:void(0)'), $tag->getAttributes());
$tag->setAttributes(array('href' => ''));
$this->assertSame('', $tag->href);
$this->assertSame('', $tag->getAttribute('href'));
$this->assertSame(array('href' => ''), $tag->getAttributes());
$tag->addClass('link');
$this->assertSame('link', $tag->class);
$tag->addClass('link-external');
$this->assertSame('link link-external', $tag->class);
$tag->removeClass('link');
$this->assertSame('link-external', $tag->class);
}
示例10: getInputElement
protected function getInputElement($config)
{
$input = new Tag('input');
$input->setAttributes(array('type' => 'radio'));
return $input;
}
示例11: getInputElement
protected function getInputElement($config)
{
if (isset($config['multiline']) && $config['multiline']) {
return new Tag('textarea');
} else {
$type = in_array($config['type'], array('text', 'password', 'search', 'email', 'url')) ? $config['type'] : 'text';
$input = new Tag('input');
$input->setAttributes(array('type' => $type));
return $input;
}
}
示例12: getInputElement
protected function getInputElement($config)
{
$input = new Tag($config['useInputTag'] ? 'input' : 'button');
$input->setAttributes(array('type' => $config['type']));
return $input;
}
示例13: getInputElement
protected function getInputElement($config)
{
if (isset($config['multiline']) && $config['multiline']) {
return new Tag('textarea');
} else {
$input = new Tag('input');
$input->setAttributes(array('type' => $this->getSaneType($config)));
return $input;
}
}