I would say if it's possible to add wysiwyg editor (CKeditor) in "HTML" pyrocms widget. I'm trying in this way, but it doesn't work:
1) In "system/cms/modules/widgets/controllers/admin.php", I've changed __constructor method:
$this->template
->set_partial('shortcuts', 'admin/partials/shortcuts')
->append_metadata(js('widgets.js', 'widgets'))
->append_metadata(css('widgets.css', 'widgets'));
to this
$this->template
->set_partial('shortcuts', 'admin/partials/shortcuts')
->append_metadata(js('widgets.js', 'widgets'))
->append_metadata(css('widgets.css', 'widgets'))
->append_metadata($this->load->view('fragments/wysiwyg', $this->data, TRUE));
2) In "system/cms/widgets/html/views/form.php", I've changed
<?php echo form_textarea(array('name'=>'html', 'value' => $options['html'])); ?>
to this
<?php echo form_textarea(array('id'=>'html', 'name'=>'html', 'value' => $options['html'], 'class' => 'wysiwyg-simple')); ?>
Do you have any suggestion?
I found a solution: you can read it here http://pyrocms.com/forums/topics/view/2552
Related
I am using some custom options as additional options on site
I am using below code to show additional options to cart page using checkout_cart_product_add_after event. it is working fine
$additionalOptions[] = array(
'code' => 'Personalize '.$j,
'label' => 'Personalize '.$j,
'value' => $personalizeData
);
$item->addOption(array(
'code' => 'additional_options',
'value' => serialize($additionalOptions)
));
//Here $personalizeData is my custom options array.
Now I want to show these options also on user's wishlist when user adds product to wishlist.
Please suggest me.
Try this,
In app/design/frontend/<your_package>/<your_theme>/template/wishlist/item/list.phtml file
<?php foreach ($this->getItems() as $item): ?>
<?php $options = $this->helper('catalog/product_configuration')->getOptions($item); print_r($options); ?>
<?php endforeach; ?>
In a Yii application I have models User and Expert ('expert'=>array(self::BELONGS_TO, 'Expert', 'expert_id'),).
There is a form for creating/editing user data. Now I want to extend it with a drop-down list:
<?php
/**
* #var $experts Expert[]
*/
$expertsDropDownListData = array();
foreach ($experts as $expert) {
$expertsDropDownListData[$expert->id] = $expert->name;
}
?>
<div class="row">
<?php
echo $form->labelEx($user, '', array('label' => Yii::t('app', 'Some text...')));
?>
<?php
echo $form->dropDownList(
$user, 'expert[id]', $expertsDropDownListData,
array(
'empty' => Yii::t('app', 'Please select an expert.'),
// 'options' => array('' => array('selected' => 'selected')),
// 'prompt'=>'Choose One',
)
);
?>
<?php echo $form->error($user, 'expert[id]'); ?>
</div>
I want the drop-down list never to have an expert entry as ould default entry. On page load alwys the empty value should be "selected". It works on pages of users, that don't have a related expert (in the users table the columnt expert_id is NULL). But on the pages of the user, that have an expert, the expert entry of the user gets selected.
How to permit the CActiveForm object selecting an antry and display a form without preselected value irrespective of the tables/objects relationships?
You can fill the attribute $model->expert with null after load.
// Controller
$user = User::model()->findByPk(1);
...your awesome code here...
// never show a default value
$user->expert=null;
if(isset($_POST)) {
// $user->expert will be set here with data from view
$user->attributes = $_POST;
}
...
// View
<div class="row">
<?php
echo $form->labelEx($user, '', array('label' => Yii::t('app', 'Some text...')));
?>
<?php
echo $form->dropDownList(
$user, 'expert', CHtml::listData($experts,'id', 'name'),
array('empty' => Yii::t('app', 'Please select an expert.'),)
);
?>
<?php echo $form->error($user, 'expert'); ?>
</div>
I'm trying to enable ajax validation in a form, I've added the right parameters to the form, but it's not working, here's my code:
<?php $form=$this->beginWidget('CActiveForm', array(
'id'=>'user-form',
'enableAjaxValidation'=>true,
'htmlOptions' => array(
'enctype' => 'multipart/form-data',
'enableClientValidation'=>true
),
)); ?>
Please advice.
In the top of your action, add the following lines:
if(isset($_POST['ajax']) && $_POST['ajax']==='user-form'){
echo CActiveForm::validate($model);
Yii::app()->end();
}
I have problem with AJAX in CakePHP. I have 2 different AJAX forms in one view. The first AJAX form works well, but the other one doesn't work properly. When I call the second AJAX, it doesn't set data from this form to $this->request->data, but the AJAX will run properly. After that, it will update <div id="about"></div>. Curious is fact, that after the div is updated and I try send data through this form again, it works and it will update my data in database. Also when I have only the second AJAX in the view, it will work properly and send the data first time I send the data through it.
Here's my code:
This is a view file:
<div id="price-list">
<?php echo $user['User']['price_list']; ?>
</div>
<?php
echo $this->Form->create('User');
echo $this->Form->input('User.price_list', array('label' => false));
echo $this->Js->submit('Save', array(
'url' => array('controller' => 'users', 'action' => 'ajax_edit_price_list'),
'update' => '#price-list',
'buffer' => false,
));
?>
<div id="about">
<?php echo $user['User']['about']; ?>
</div>
<?php
echo $this->Form->create('User');
echo $this->Form->input('User.about', array('label' => false));
echo $this->Js->submit('Save', array(
'url' => array('controller' => 'users', 'action' => 'ajax_edit_about'),
'update' => '#about',
'buffer' => false,
));
?>
I have also append <?php echo $this->Js->writeBuffer(); ?> in my default.ctp before </body>.
Do you have any idea, where can be a problem? Thanks
I wasn't able to reproduce your exact issue, but I think I know the problem. Your second form is being created inside of the first form. You need to add echo $this->Form->end(); to the end of both forms.
Also, the forms are getting created with the same ID. Although this isn't what's causing the problem, it's still not good. I suggest you take thaJeztah's advice and specify an ID manually inside $this->Form->create().
here is what i am trying to achieve...
i have a index view in which i have used the ajax helper not the cakephp one but an external one from http://www.cakephp.bee.pl/
i have succefully created an accordion using this helper.
now inside the accordion i have an addbutton which submits a form via ajax.
what i would like to do is when i submit the ajax form. i would also like to update the accordion.
now the accordion is also created by using the ajax helper.
Can this be done without a page refresh
ajax submit form code :
<div class="qnotesform">
<?php echo $this->Form->create('Qnote');?>
<ul class="qnotelist">
<li><?php echo $this->Form->input('Qnote.subject', array('label'=>'Title', 'rows' => '1')); ?></li>
<li> <?php echo $this->Form->input('Qnote.body', array('label'=>'Header', 'rows' => '1')); ?></li>
<?php echo $this->Form->hidden('Qnote.user_id', array('value'=>Authsome::get('id'))); ?>
<?php echo $this->Form->hidden('Step.0.user_id', array('value'=>Authsome::get('id'))); ?>
<li><?php echo $this->Form->input('Step.0.body', array('label'=>'Steps' ,'class' => 'step', 'rows' => '1')); ?></li>
</ul>
<?php echo $ajax->submit(
'Submit', array(
'url' => array(
'controller'=>'qnotes',
'action'=>'add')
));
how can i achieve this .
could someone please point me the right direction
another thing that i want to clear out is. If i want to be working one page . and all crud
action to be used without a page refresh.
does anybody have a working example for the above senarios .
or let me make it simple.
how to refresh a div without refreshing the page.
Solution:
code
<?php echo $ajax->submit('Submit', array(
'url'=> array(
'controller'=>'qnotes',
'action'=>'add'),
'update'=>'leftdiv',
'after'=>'$("#accordion").accordion({autoHeight: false, collapsible: true , header: "h3"});alert("after");',
));
however now I am facing another issue now,
I am updating the accordion, everything works fine but as soon as update the accordion.
the accordion loses its style class and stops working.
I only see links then. any idea how.
It seems that one of the options in the array of the submit method is 'complete' which should allow you to trigger a js function that will update your accordion:
<?php echo $ajax->submit(
'Submit', array(
'url' => array(
'controller'=>'qnotes',
'action'=>'add',
'complete' => 'updateAccordian(request.responseText)')
));
the reuqest.responseText will contain the reponse from your controller/action.
HTH