Posts Tagged with attribute

Displaying 1-5 of 5 results.
Resolved: Yii 1.1 How to get attribute from model attributeLabels function in CDetailView custom field
posted by admin on October 12, 2016
I have this CDetailView

<?php $this->widget('zii.widgets.CDetailView', array(
'data'=>$model,
'attributes'=>array(
'id',
'username',
'personal_email',
'work_email',
array(
'label' => Yii::t('translation', 'Created'),
'type' => 'raw',
'value' => app::datetimeUserFriendly($model->created),
),
'updated',
. . .
),
)); ?>

I want to read label from model attributeLabels.Read more
Resolved: Yii CGridView custom column not and not show html data attribute
posted by admin on April 24, 2016

echo CHtml::link(
CHtml::image(Yii::app()->request->baseUrl.'/images/op-create.png', "image", array("width"=>30)),
Yii::app()->request->baseUrl.'/images/op-create.png',
array("class"=>"highslide", 'rel'=>'myrel'));

output :

<a class="highslide" rel="myrel" href="/web/images/op-create.png"><img width="30" src="/web/images/op-create.png" alt="image" /></a>



$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'loc-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
array('name'=>'loc_picture',
'type'=>'html',
'header'=>'Picture',
'value'=> 'CHtml::link(CHtml::image(Yii::app()->request->baseUrl.$data->loc_picture, "image", array("width"=>30)), Yii::app()->request->baseUrl.$data->loc_picture, array("class"=>"highslide", \'rel\'=>\'myrel\'))',
'htmlOptions'=>array('width'=>'40','style'=>'text-align:center;'),
),
),
));

output :

<a class="highslide" href="/web/pictures/noimage.jpg"><img width="30" src="/web/pictures/noimage.jpg" alt="image" />

Why output in CGridView, REL="myrel" not shown???Read more
Wiki: Yii on update, detect if a specific AR property has been changed on beforeSave()wiki
posted by admin on April 23, 2016
You need to store the old attributes in a local property in the AR class so that you can compare the current attributes to those old ones at any time.

Step 1. Add a new property to the AR class:

// Stores old attributes on afterFind() so we can compare
// against them before/after save
protected $oldAttributes;


Step 2. Override Yii's afterFind() and store the original attributes immediately after they are retrieved.

public function afterFind(){
$this->oldAttributes = $this->attributes;
return parent::afterFind();
}


Step 3. Compare the old and new attributes in beforeSave/afterSave or anywhere else you like inside the AR class. In the example below we are checking if the property called 'level' is changed.

public function beforeSave()
{
if(isset($this->oldAttributes['level']) && $this->level != $this->oldAttributes['level']){

// The attribute is changed. Do something here...

}

return parent::beforeSave();
}
Read more
Wiki: Attribute Equals Selector [name=”value”]wiki
posted by admin on April 12, 2016
Description: Selects elements that have the specified attribute with a value exactly equal to a certain value.

jQuery( "[attribute='value']" )
attribute: An attribute name.

value: An attribute value. Can be either an unquoted single word or a quoted string.

Example:

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>attributeEquals demo</title>
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
</head>
<body>

<div>
<label>
<input type="radio" name="newsletter" value="Hot Fuzz">
<span>name?</span>
</label>
</div>
<div>
<label>
<input type="radio" name="newsletter" value="Cold Fusion">
<span>value?</span>
</label>
</div>
<div>
<label>
<input type="radio" name="newsletter" value="Evil Plans">
<span>value?</span>
</label>
</div>

<script>
$( "input[value='Hot Fuzz']" ).next().text( "Hot Fuzz" );
</script>

</body>
</html>

Finds all inputs with a value of "Hot Fuzz" and changes the text of the next sibling span.Read more
Resolved: JavaScript jQuery add attribute to links, which is not belong to website and locate to another resource
posted by admin on March 11, 2016

<a href="http://isystems.am">sadsa dasd as ds</a>
<a href="http://forum.isystems.am"> sd s f f d f</a>
<a href="http://autoservice.am"> sd s f f d f</a>
<a href="http://classyluxury.ru"> sd s f f d f</a>
<a href="http://polusportpoluklassika.ru"> sd s f f d f</a>
<a href="http://classystyle.ru"> sd s f f d f</a>


I want to add attribute to my all links, which is not locate to my website. I want to open another links in new window, not in self window. I want to do it after page will be loaded.Read more