Decorators for Zend_Dojo_Form - dojo

I have a Zend_Dojo_Form and like to change the decorator for it:
//inside my Zend_Dojo_Form
$this->setDecorators(array(
'FormElements',
'DijitForm',
array(array('tr' => 'HtmlTag'), array('tag' => 'tr')),
array(array('table' => 'HtmlTag'), array('tag' => 'table')),
));
The rendered form looks fine but if I submit only Zend_Form_Elements, but no Zend_Dojo_Form_Elements are POSTed. If I do not change the decorators, all values are submitted, but the layout is (of course) broken. Do I miss some essential decorator?

The problem turned out to be more html than zend related
$this->setDecorators(array(
'FormElements',
array(array('tr' => 'HtmlTag'), array('tag' => 'tr')),
array(array('table' => 'HtmlTag'), array('tag' => 'table')),
'DijitForm',
));
works, because now the form elements spans the whole table.

Related

CJuiDatePicker in yii is not working

In my web application, I want to implement a date field. For this i am using CJuiDatePicker. But for me it not showing calendar.
My code is,
$this->widget('zii.widgets.jui.CJuiDatePicker', array(
'name' => 'Employee[employee_joiningdate]',
'id' => 'Employee_employee_joiningdate',
'value' => Yii::app()->dateFormatter->format("d-M-y", strtotime($model->employee_joiningdate)),
'options' => array(`
'showAnim' => 'slide', //'slide','fold','slideDown','fadeIn','blind','bounce','clip','drop'
'showOtherMonths' => true, // Show Other month in jquery
'selectOtherMonths' => true, // Select Other month in jquery
),
'htmlOptions' => array(
'class' => 'form-control'
),
));`
What i am doing wrong?
Please help me....
Thanks in advance.

Yii Parameterized Hostnames. what am I missing?

I am not able to get the yii parameterized hostnames working. I am trying to display http://member.testsite.com when the user clicks on login from http://www.testsite.com.
I have the member module created with SiteController.
In my rules, I have:
'rules' => array(
'<controller:\w+>/<id:\d+>' => '<controller>/view',
'<controller:\w+>/<action:\w+>' => '<controller>/<action>',
'<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
'http://member.testsite.com' => 'member/site/index',
),
In my login, I have the URL pointing to
'url'=>array('member/site/index')
When I hover over login, it shows member.testsite.com, but when I click it takes me to website-unavailable.com
When I change the rules to
'http://member.testsite.com' => 'member/<controller>/<action>',
it takes me to testsite.com/member/site/index/
Am I missing any step?
Example:
'rules' => array(
'://<member:\w+>.<host>/<controller:\w+>/<action:\w+>'
=> '<controller>/<action>',
),

Yii CListView summary text

Is there any way to hide "Summary" for CListView without loosing pagination. By summary i mean text like "Displaying 1-2 of 2 result(s).". Or maybe I should use different widget?
Try the following to get more control over the look of your CListView output:
'template'=>'{items} {pager}'
You can even use HTML in the template.
Ok, I didn't get it at first, when looking into CListView code, but setting 'summaryText' to '' will do the work. I've realised that second time when I was staring at $summaryText === null
$this->widget('zii.widgets.CListView', array(
'dataProvider'=>$dataProvider,
'summaryText'=>'',
'itemView'=>'_indexview',
));
Here is the example for CListView:
$this->widget('zii.widgets.CListView', array(
'dataProvider' => $dataProvider,
'itemView' => '_view',
'ajaxUpdate' => false,
'emptyText' => 'No records found.',
'summaryText' => "{start} - {end} из {count}",
'template' => '{summary} {sorter} {items} {pager}',
'sorterHeader' => 'Sort by:',
'sortableAttributes' => array('title', 'price'),
'pager' => array(
'class' => 'CLinkPager',
'header' => false,
'cssFile' => '/css/pager.css',
'htmlOptions' => array('class' => 'pager'),
'maxButtonCount' => '10',
'prevPageLabel'=>'←',
'nextPageLabel'=>'→',
'header'=>'Pages: ',
),
));
You should try this:
'summaryText' => FALSE,
You may hide it by adding CSS in the page like below.
<style>
.summary{
display:none;
}
</style>
Here is my suggestion
$this->widget('zii.widgets.CListView', array(
'dataProvider' => $best_seller_data,
'itemView' => 'alsoBestseller',
'summaryText'=>false,
));

Error with dijit.form.NumberTextBox

Despite many trials and errors, I cannot get the NumberTextBox widget to work. I keep receiving this error message:
Catchable fatal error: Argument 4 passed to Zend_Dojo_View_Helper_NumberTextBox::numberTextBox() must be an array, null given
The odd thing is: I event tried this example straight from the ZF examples page and it failed with the same error
->addElement(
'NumberTextBox',
'numberbox',
array(
'label' => 'NumberTextBox',
'required' => true,
'invalidMessage' => 'Invalid elevation.',
'constraints' => array(
'min' => -20000,
'max' => 20000,
'places' => 0,
)
)
)
So, I'm at a loss now. If someone has the time to look at the code found here, your help would be greatly appreciated. I know it's something that I'm overlooking. It always is.
If you are setting decorators, make sure you change ViewHelper to DijitElement. I ran into this problem and that was the cause.
Shot in the dark: try getting rid of the ',' at the end of 'places' => 0,'
I use a base Form,
BaseForm extends Zend_Dojo_Form{
public $elementDecorators = array(
'DijitElement',
array(
array('data' => 'HtmlTag'),
array('tag' => 'div', 'class' => 'element')
),
array('Label',
array('tag' => 'div', 'class' => 'element-label')
),
array(array('row' => 'HtmlTag'),
array('tag' => 'div', 'class' => 'element-row' )
)
);
... init(){}
.... construct(){}
}
MyForm extends BaseForm{
constructor(){
$this->starts = new Zend_Dojo_Form_Element_DateTextBox( "starts" );
$this->starts->setLabel('Starting from')
->setDecorators($this->elementDecorators);
}
}
I made the source code as simple as possible, to depict the idea of what I mean.

Zend_Form decorators ordering (Errors before form element issue)

I have the following Zend_Form code to apply to form element decorators:
$decorators = array(
'ViewHelper',
'Description',
array('break' => 'HtmlTag', array('tag' => 'br', 'openOnly'=>true)),
array('Label', array('class' => 'formLabel', 'separator'=>' ', 'requiredSuffix' => ' <em class="requiredFormElement">(requried)</em>', 'escape'=>false)),
array('Errors', array('class' => 'formErrors')),
array(array('row' => 'HtmlTag'), array('tag' => 'div')),
);
It seems no matter what I do I can't seem to make the Errors show up before the form element (and label) itself. Am I missing something? Everything else seems to be ordered correctly. Can this only be done with a custom decorator?
Thank you in advance.
Try the following, don't know if it'll work, since I don't have my laptop at the moment:
array('Errors', array('class' => 'formErrors', 'placement' => 'prepend'))