Probleme with the update of Sonata adminBundle - sonata-admin

i can't make update in sonata bundle ,i have only create or delete in liste action please help !
you can see with this that i have only the create or the delete action

If you didn't override configureRoutes(RouteCollection $collection) function in your admin class, then you should have the edit route enabled.
In configureListFields(ListMapper $listMapper) function, put
$listMapper->addIdentifier('name');
instead of
$listMapper->add('name');
This will create a link on the name of your entity and you will be able to edit it.
Hope it helps! :)

Related

CakePHP - can't create more than one method (admin_index) in plugin

I'm a newbie in CakePHP, please have patience with me :)
So, I'm trying to create a plugin called References. I've baked "plugin's core" through cake's console. Then I've created ReferencesController class that extends ReferencesAppController and Reference class (model) that extends ReferencesAppModel. My next step was creating action admin_index (just code to save form), it's view and a little bit validation in Reference model. To my problem, I'm unable to create any other action, ex. admin_add. When I do (I create new action and I add it's view), then I try to access it through the URL (localhost/my_project/admin/references/add), and there comes the message "Error: References.AddController could not be found.". I am not sure, what I do wrong, I don't want to create another controller, just action. Thank you
Because only the plugin index action (when plugin and controller have the same name) is directly routed.
For all others you need to verbosly add the plugin name and the controller name to the url:
/my_project/admin/references/references/add
If you had created a link to this action, the routing would have shown you that.

Setting permissions in cakephp Pages controller

I followed Andrew Perkins excellent tutorial on setting up permissions in CakePHP 2.0.
My question, however, relates to how to use the allow and deny method in the Pages controller. Currently I have $this->Auth->allow('display') which allows all methods in the Pages controller to be view.
What if I only want the home page allowed but the rest denied? How do I code that?
Thanks in advance.
Make sure you have copied the PageController.php to your app/Controller folder. Then, add a beforeFilter callback method and set access based on the passed page parameter:
public function beforeFilter() {
// Use $this->request->pass to get the requested page name/id
// Decide on access with $this->Auth->allow()
}
This should solve your problem.
You can find more information on request's lifecycle in CakePHP manual. That's pretty useful stuff.
Have you tried this code?
You can out it into your PageController or into your Controller directly
$views = array ('index'); //array of view that you want allow
$this->Auth->allow($views);

Episerver nested master page from EPiServerUI.master

I want to have my custom master page for all GuiPlugIn reports. As we know, by default GuiPlugIn referes to EPiServerUI.master page which is part of installation. I want to create a nested master page for my GuiPlugIn instead of default.
Please share your thoughts.
Thanks,
Kris
I think the reason that you cannot change master page for a plugin is for visual consistency. You could try to change the master page through code like this (assuming your plug in is a user control:
protected override void OnInit(EventArgs e)
{
this.Page.MasterPageFile = "~/NewMaster.master";
}
Maybe there is a better way to do what you want, if you provide more detail?
You can always access the Page object if you want to inject custom css or scripts to use with your plugin like this:
HtmlGenericControl js = new HtmlGenericControl("script");
js.Attributes["type"] = "text/javascript";
js.Attributes["src"] = "mylibrary.js";
this.Page.Header.Controls.Add(js);

Prefix route I want to create already exists as controllers

I'm new to cakephp so go easy on me!
I have a table called promoters and users can be promoters.
I want to create a "promoters dashboard/control panel". To do this I wanted to create a prefix route of "promoters".
E.g. you go to http://mywebsite.com/promoters/events/add you get to the promoter_add function within EventsController.
So the problem is that I actually have a controller called PromotersController which I need for the admin users (e.g. http://mywebsite.com/admin/promoters/add).
I hope you're following.
So... my question is, will I just have to do what I think I'm going to have to do which is to create a different prefix route? Maybe call it promos or something?
Or can I create a prefix route of promoters and just have it override the controller named PromotersController if it needs to?
Thanks
Can't you just add the promoters dashboard method to the PromotersController?
class PromotersController extends AppController {
public function dashboard() {
}
}
you can then visit:
/promoters/dashboard

Using Ajax with cakephp

HI I am new to cakephp so any help would be grateful.
I have created a form and with one of the fields when the user has filled in checks to see it it already exists and offers other suggestions. I have used the Ajax observerField method to do this. I want the user to be able to click on the suggested names(radioboxes) and then it update the field in the other form. What is the best way to achieve this in cakephp?
If it was me, I would create a form field
echo $form->input('otherfield');
Then use javascript to catch the click on the suggested radio, and copy the value into that field.
In jQuery,
$('#suggestions input[type=radio]').click(function(){
$('#otherfield').val() = $(this).val();
});
Then when the form is submitted you will have it in,
$this->data['Model']['otherfield']

Resources