dropdown checkbox list cakephp - 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>

Related

Concatenation with %keyword in mini-panels

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

Use link cakephp with angular

Could be possible to use {{ somethingAngular }} inside a link cakephp, or Need I to convert my aplication to angular using html link or img tags?
For example, I cant do this:
<?php echo $this->Time->format('d', '{{ video.Video.created }}'); ?>
Error
Regards!

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)));
?>

view content from Controller and view on a separate controller and view

I have a
Controller/PostsController.php
Model/Post.php
View/Posts/Index.ctp
if anyone has followed the cakephp blog tutorial i have completed that.
Anyone who hasnt, its basically a site that lets you add a title and a comment. Much like a forum.
Now i have this set up , but i want to include a new page called home. And on this page i wont to display the forum i created but in a smaller container.
I am unsure how to add the view of Posts to a new controller/model/view.
This is PostsController.php:
class PostsController extends AppController {
public function index() {
$this->set('posts', $this->Post->find('all'));
}
}
This is View/Posts/index.ctp
<table>
<tr>
<th>Id</th>
<th>Title</th>
<th>Actions</th>
<th>Created</th>
</tr>
<!-- Here's where we loop through our $posts array, printing out post info -->
<?php foreach ($posts as $post): ?>
<tr>
<td><?php echo $post['Post']['id']; ?></td>
<td>
<?php
echo $this->Html->link(
$post['Post']['title']
);
?>
</td>
<td>
<?php echo $post['Post']['created']; ?>
</td>
</tr>
<?php endforeach; ?>
</table>
so with this, how do i get the same posts to include on a new controller and view, lets say:
HomesController.php
View/Homes/index.ctp
EDIT//EDIT//EDIT
right i have managed to do half of this now by adding
$this->render('/Abouts/index');
to my PostsController
but now i get an error saying
"Undefined variable: posts [APP\View\Abouts\index.ctp, line 12]"
im not sure how to define these in my abouts view
In the 'abouts' action, you'd do the same thing you were doing in the index:
$this->set('posts', $this->Post->find('all'));
Site note: Seems like it would be worth your time to go through the blog tutorial again for a refresher. I believe this kind of thing is covered pretty thoroughly.
From cakephp books
Many applications have small blocks of presentation code that need to be repeated from page to page, sometimes in different places in the layout. CakePHP can help you repeat parts of your website that need to be reused. These reusable parts are called Elements. Ads, help boxes, navigational controls, extra menus, login forms, and callouts are often implemented in CakePHP as elements. An element is basically a mini-view that can be included in other views, in layouts, and even within other elements. Elements can be used to make a view more readable, placing the rendering of repeating elements in its own file. They can also help you re-use content fragments in your application.
So, for your purposes use elements, more information here

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>');
});

Resources