I'm trying to use an activeCheckboxlist in a form in my Yii site. When generating the checkboxlist, Yii automatically puts a < br > between the checkboxes.
Is there any way to avoid/override this except with CSS?
Yes, you can do that by give 'separator' param in htmlOptions
echo CHtml::activeCheckboxList($model, $attribute, $dataArr,
array(
//..
'separator'=>'|', //new separator. html allowed also
//'template'=>'<span class="myItem">{label} {input}</span>', // use template to customize each item
//..
));
http://www.yiiframework.com/doc/api/1.1/CHtml#activeCheckBoxList-detail
Related
I want to add a title tag to each checkbox of a Zend_Form_Element_MultiCheckbox, to use jquery tooltip.
I use zend 1.12.
here is the way I make my multicheckbox :
$orderValue = new Zend_Form_Element_MultiCheckbox(Frontend_Model_SiteDetail::CHAMP_ORDER_VALUE);
$orderValue->setLabel($translate->_(Frontend_Model_VueSiteDetail_Parametres::CHAMP_ORDER_VALUE_TITLE))
->setMultiOptions(Frontend_Model_Enum_GroupOrder::getInstance()->getAll(true))
->setDecorators($decorateurs);
my decorator is :
$decorateurs = array('Composite_Table');
I try something like this but it didn't work :
$orderValue->removeDecorator('HtmlTag');
$orderValue->addDecorator('HtmlTag', array(
'attribute' => 'title'
));
I use this method:
$orderValue->setAttrib('title', 'Tooltip');
i've been using Yii framework for some time now, and i've been really having a good time especially with these widgets that makes the development easier. I'm using Yii bootsrap for my extensions..but i'm having a little trouble understanding how each widget works.
My question is how do i display the widget say a TbDetailView inside a tab?
i basically want to display contents in tab forms..however some of them are in table forms...some are in lists, detailviews etc.
I have this widget :
$this->widget('bootstrap.widgets.TbDetailView',array(
'data'=>$model,
'attributes'=>$attributes1,
));
that i want to put inside a tab
$this->widget('bootstrap.widgets.TbWizard', array(
'tabs' => $tabs,
'type' => 'tabs', // 'tabs' or 'pills'
'options' => array(
'onTabShow' => 'js:function(tab, navigation, index) {
var $total = navigation.find("li").length;
var $current = index+1;
var $percent = ($current/$total) * 100;
$("#wizard-bar > .bar").css({width:$percent+"%"});
}',
),
and my $tabs array is declared like this :
$tabs = array('studydetails' =>
array(
'id'=>'f1study-create-studydetails',
'label' => 'Study Details',
'content' =>//what do i put here?),
...
...);
when i store the widget inside a variable like a $table = $this->widget('boots....);
and use the $table variable for the 'content' parameter i get an error message like:
Object of class TbDetailView could not be converted to string
I don't quite seem to understand how this works...i need help..Thanks :)
You can use a renderPartial() directly in your content, like this:
'content'=>$this->renderPartial('_tabpage1', [] ,true),
Now yii will try to render a file called '_tabpage1.php' which should be in the same folder as the view rendering the wizard. You must return what renderPartial generates instead of rendering it directly, thus set the 3rd parameter to true.
The third parameter that the widget() function takes is used to capture output into a variable like you are trying to do.
from the docs:
public mixed widget(string $className, array $properties=array ( ), boolean $captureOutput=false)
$this->widget('class', array(options), true)
Right now you are capturing the object itself in the variable trying to echo out an object. Echo only works for things that can be cast to a string.
How can I enable Markdown formatting for a specific column in GridView and ListView?
You can use custom functions to process columns. If you have PHP 5.3 you can do it the following way:
'columns'=>array(
array(
'name'=>'My markdown column',
'value'=> function($data, $row){
$parser = new CMarkdownParser();
// if data is entered by user you can purify it using safeTransform
return $parser->transform($data);
}
),
)
For PHP <5.3 it's the same except you should wrap your code into a string and avoid using anonymous function.
I created element in form object:
function createElement()
{
$template = new Zend_Form_Element_Hidden('field');
$template->addDecorator('ViewScript', array('placement' => 'prepend', 'viewModule' => 'admin', 'viewScript' => 'values.phtml'))
$this->addElement($template);
}
function setViewTemplate($values)
{
$view = new Zend_View();
$view->setScriptPath(APPLICATION_PATH . '/scripts/');
$view->assign('values', $values);
$this->getElement('field')->setView($view);
}
But in the view script 'values.phtml' I cannot get access to values like $this->values.
What I'm doing wrong here?
I know that it would be good to add own decorator, but it is interesting to use zends' decorators.
From the Zend Framework Documentation: Standard Form Decorators Shipped With Zend Framework Section
Zend_Form_Decorator_ViewScript
Additionally, all options passed to
the decorator via setOptions() that
are not used internally (such as
placement, separator, etc.) are passed
to the view script as view variables.
function setViewTemplate($values)
{
$this->getElement('field')
->getDecorator('ViewScript')
->setOptions('values', $values);
}
you can reslove it with using attribs
$template->setAttrib('key', 'value');
and in template
<?php echo $this->element->getAttrib('key'); ?>
Is there any way to change the layout of a facet?
I know you can create a file in the template dir named: block-apachesolr_search-[field].tpl.php
The problem I am having is that at this stage the html in the block variable has already been created.
Is there any way to change the html or just get the elements of the facet?
Thanks!!
are you talking about faceted search module?
you could overwrite stuff by adding it in your template file or something simmilar, forinstance i had to add the "clear-block" to a div and did it this way:
function themename_faceted_search_ui_facet_wrapper($env, $facet, $context, $content) {
$classes = array(
'faceted-search-facet', // Note: Tooltips rely on this class.
'faceted-search-env-'. $env->name,
'faceted-search-facet--'. check_plain($facet->get_key() .'--'. $facet->get_id()), // Note: Tooltips rely on this class.
'faceted-search-facet-'. ($facet->is_active() && $context != 'related' ? 'active' : 'inactive'),
'faceted-search-'. $context,
);
return ''. $content .''."\n";
}
took a while to find the right function in the module file, but i dont know of any other way.