Concatenation with %keyword in mini-panels - drupal-7

Someone posted another question https://drupal.stackexchange.com/questions/195860/how-does-one-concatenate-fields-in-title-field-in-panels-pages but its not working for me.
I need to concatenate a custom text as prefix with %node:field_city_title keyword while adding a node field in mini-panels.
I tried with Event in %node:field_city_title , Event in%node:field_city_title and searched a lot but nothing works for me.
If you any idea, let me know

I've figured out but not sure either it's a standard way or not but I believe override title field is not accepted "prefix or postfix" for %keyword like mentioned in the question.
Solution
1) Removed tag h1 from the attached image in the question.
2) Created new tpl named as panels-pane--event-node-title.tpl.php and added some code in it
<div class="pane-content">
<?php if ($title): ?>
<h1> <?php print $title; ?> </h1>
<?php else : ?>
// Here we can set any prefix or postfix within the tag
<h1> Event in <?php print render($content); ?> </h1>
<?php endif; ?>
</div>
$content variable will get content of the field along with its all settings (ID, class, tag etc.)
Hope, this will help someone. Thanks

Related

Delete div generated by CakePHP Form create

CakePHP Code
<?php echo $this->Form->create('KPI');?>
HTML Output
<form accept-charset="utf-8" method="post" id="..." action="...">
<div style="display:none;">
<input type="hidden" value="POST" name="_method">
</div>
I want to delete auto generated div which display in html output. How can delete that div which generated by cakephp form create?
As already mentioned in the comments, you should not remove that markup, besides that would only be possible by completely overwriting FormHelper::create(), see
https://github.com/.../cakephp/blob/2.5.6/lib/Cake/View/Helper/FormHelper.php#L426-L432
https://github.com/.../cakephp/blob/2.5.6/lib/Cake/View/Helper/FormHelper.php#L462-L464
Also note that there might be an additional hidden block at the end of the form, see FormHelper::secure().
The only simpler way to remove the wrapper, would be to remove the hidden wrappers altogether, that would for example be possible by using a custom config for HtmlHelper where the hiddenblock tag is modified so that it doesn't contain the wrapper, however that's not a good idea - don't do it!
The problem here is that you can't just remove this specific wrapping div element, the hidden input and the div go hand in hand. And the input ensures that CakePHP is able to figure the proper request method (POST, PUT, DELETE).
So instead simply make your jQuery selector more specific, do not just select div elements, instead make sure that your elements have a proper class set, and then select them by that class.
<?php echo $this->Form->create('Kpi', array(
'inputDefaults'=>array('div'=>'false', 'label'=>false)));
?>

dropdown checkbox list cakephp

Can we do something like image below on cakephp. If can, how to do it? I am struggle with it. I try to find any answers but can not found something like this. Any answers for this problem will be great appreciated.
This can also be done with Bootstrap as well. The functionality is generally the same as #Anubhav 's answer from a bit earlier, however this is a little cleaner and a more up to date solution. The Bootstrap Framework is maintained/updated a lot more frequently.
See here for full solution:
Bootstrap dropdown checkbox select
No you cant do this using only CakePHP... but the above thing can be done using jQuery.
Please follow the link and your task will be done easily
http://dropdown-check-list.googlecode.com/svn/trunk/doc/dropdownchecklist.html
Cheers
multiple dropdown options with checkbox in cakephp error
<div class="col-md-2 place-grid">
<h5>Property Type</h5>
<?php $allCategories=$this->Common->getCategories(); ?>
<?php echo $this->Form->input('ptype',array('options' =>$allCategories,'style'=>'width:150px;','error'=>false,'id'=>'ptype','onchange'=>'getIdType()','div'=>false,'label'=>false,'empty'=>'Select Type','class'=>"sel")); ?>
<?php if($this->Form->error('ptype')){?>
<?php echo $this->Form->error('ptype',array('style'=>'txtError'));?>
<?php } ?>
</div>
<div class="col-md-2 place-grid">
<h5>Sub Type</h5>
<?php $allSubCategories=$this->Common->getArticleSubCategories(); ?>
<?php echo $this->Form->input('sptype',array('options'=>'', 'style'=>'width:150px;','error'=>false,'div'=>false,'select'=>true,'label'=>false,'empty'=>'fgfg','class'=>"sel")); ?>
</div>

AngularJS and ns-select without ng-option

in my page I load the content of a div via "ng-include src". In this content I have a <select> item:
<select name="relationship" ng-model="userEdit.relationship">
<?php
$tree = taxonomy_get_tree(5);
foreach ($tree as $row) {
echo "<option value=".$row->tid.">".$row->name."</option>\n";
}
?>
</select>
In my "controller" function I can not to create this tree into an array to pass to "ng-options" because I have no access to source tree via web. I can only read the full HTML form. I can change the source of the form (if I need to inject something for example) but I can not get the original tree in my controller.
However, the HTML is ok, but when I choose my "relationship" and send the form (ng-click="myfunction()") to my controller function i can see that there is no "relationship" in "userEdit" object.
Where is my error ?
Thanks.
You are missing quotes
echo "<option value='".$row->tid."'>".$row->name."</option>\n";

Custom Input HTML with CakePHP's FormHelper

I'm trying to use CakePHP's form helper to generate some input elements.
The HTML I am trying to generate is:
<div class="formRow">
<label>LabelText:</label>
<div class="formRight">
<input name="data[User][email_address]" type="text" value="">
</div>
<div class="clear"></div>
</div>
Ive had a look through the Cake documentation (Using 2.1) and I can't find enough information on how to do this.
It looks like I need to use the format option on the input method, but can't figure out how to get it right. Especially concerned about the div surrounding the input field with a class name on it..
E.g. Ive tried something like this:
echo $this->Form->input('email_address', array(
"input" => array('attributes' => array('wrap' => 'div','class' => 'formRight'))));
But this doesnt change any of the markup and just throws this error:
Notice (8): Array to string conversion [CORE\Cake\View\Helper.php, line 459]
So my question is how can I get this form helper to create that markup?
Any help much appreciated
You're over-thinking it. (No worries, we all do). Just remember, CakePHP is all about making things easier for you (among other things) - if you're struggling with trying to force Cake to do something for you, just remember, you can fall back to the basics - it's just PHP/HTML after-all.
<div class="formRow">
<label>LabelText:</label>
<div class="formRight">
<?php echo $this->Form->input('email_address', array(
'div'=>false, 'label'=>false)); ?>
</div>
<div class="clear"></div>
</div>
You should use the Form helper for your forms when possible, but you don't have to use all of it's presets like surrounding divs & labels. In the case above, just tell it you don't want the div, and wrap it with a div yourself.
If you don't want <div>s or <label>s around any inputs, you can also set the form's inputDefaults:
$this->Form->create('Whatever', array(
'inputDefaults' => array('label'=>false, 'div'=>false)
));
If you have a lot of fields, you can use Jquery.
php:
echo $this->Form->input('email_address', array('class' => 'formRow'));
Jquery:
$(".formRow").each(function() {
$(this).wrapInner( "<div class='formRight'></div>");
$(this).find("label").prependTo(this);
$(this).append('<div class="clear"></div>');
});

How to pass an array as a hidden field?

I am implementing an auto complete box using the Ajax.autocompleter method of the scriptaculous.js framework.
This is the auto complete box and the div where the auto suggested entries are populated.
<?php echo $form->create('Share', array('url' => '/forms/share')); ?>
<label for="shareWith">Share Form with</label>
<input type="text" id="autocomplete" name="autocomplete_parameter"/>
<div id="autocomplete_choices" class="autocomplete"></div>
<input type="hidden" id="sharedUserId" name="sharedUserId"/>
<?php echo $form->end('Share');?>
This is the JQuery function to get the auto-suggested list and to get the id of the selected entry which is stored in the hidden field of the form.
new Ajax.Autocompleter("autocomplete", "autocomplete_choices",
"http://localhost/FormBuilder/forms/autoComplete",
{
tokens: ',',
afterUpdateElement : getSelectedId
}
);
function getSelectedId(text, li) {
$("#sharedUserId").val(li.id);
}
Suppose if I select multiple entries,how to send those values?
Can I have an array as a hidden field, so that I can have an array of the selected elements and save that array as a hidden field?
Simply create a new hidden input field for every selected ID, and make sure that for each you have name="sharedUserId[]". This doesn't follow the CakePHP form element naming convention, but it will make sure that the POSTed value of sharedUserId is an array.
serialize with json and parse it in the server back. PHP 5.2 can parse json natively.
Not related to your question though..
http://docs.jquery.com/Plugins/Autocomplete
jQuery Auto complete you

Resources