Disabled field in custom admin generator field

This is for discussion, mainly on 1.x but there's some 2.x topics here too.

Moderators: dwhittle, Ian

Disabled field in custom admin generator field

Postby johnyspot » Tue May 06, 2008 7:57 am

Hi !

I try to make custom field for admin generator. In my model (Art.php e.g.) I add methods

Code: Select all
public function getTags() {
...
return 'string';
}

public function setTags($v) {
}


To my admin generator I add:

Code: Select all
edit:
      display: [title, content, tags, category_id, created_at]
      fields:
        tags: { name: Tags }
        content: { params: '<?php echo sfConfig::get('app_tinymce_article_options'); ?>' }


I have the field "Tags" in edit view but this field is gray - inactive. I can see the value of this field, but I can't modified it.

Thank You for any help.
johnyspot
Junior Member
 
Posts: 8
Joined: Mon Dec 10, 2007 10:07 am
Location: Poland

Re: Disabled field in custom admin generator field

Postby animalmother » Wed May 07, 2008 2:23 am

2 methods are not enough to create an extra field in your edit-form :D
anyhow you can add an extra element to the list-view. but thats easier, because the user can't change anything.

solution:
1. create a partial-file with the form-elment of your choice and save it into [your-module]/templates/_bla.php
(the generated inputs by the admin gen are good examples)
2. overload the cached update[MODULE]FromRequest() method in [your-module]/actions/actions.class.php and add your code to handle the value of the extra elements in the request.
3. to integrate that new partial in the edit-form use the display key in the generator.yml: display: [_bla]

regards,
yannick
animalmother
Junior Member
 
Posts: 20
Joined: Fri Dec 21, 2007 1:14 am
Location: ger/hh

Re: Disabled field in custom admin generator field

Postby johnyspot » Wed May 07, 2008 6:08 am

Thank you ! (but documentation is not exactitude

"if there is a getter and/or a setter, it can also be used in the edit view."

So i thought that it "just works"

http://www.symfony-project.org/book/1_0/14-Generators#Custom %20Fields
)
Last edited by johnyspot on Wed May 07, 2008 6:48 am, edited 1 time in total.
johnyspot
Junior Member
 
Posts: 8
Joined: Mon Dec 10, 2007 10:07 am
Location: Poland

Re: Disabled field in custom admin generator field

Postby animalmother » Wed May 07, 2008 9:21 pm

"if there is a getter and/or a setter, it can also be used in the edit view."

sry, never tried that.
but, i guess, SOMEWHERE you HAVE TO define what html-form-tag you want to use for that custom field. only possible then in the generator.yml with somethin like:
title: { name: Title, type: input_tag }

if those 3 parts (getter, setter, type-definition) suffice to do it,.. that would be new to me :D
let me know

yannick
animalmother
Junior Member
 
Posts: 20
Joined: Fri Dec 21, 2007 1:14 am
Location: ger/hh

Re: Disabled field in custom admin generator field

Postby iv_ » Tue Jun 28, 2011 2:29 pm

the solution for this problem:

the "tags" field must be explicitly marked as "disabled=false" in the "fields" section in the generator.yml. your "edit" part must look lik this:

Code: Select all
edit:
      display: [title, content, tags, category_id, created_at]
      fields:
        tags: { name: Tags, params: disabled=false }
iv_
Junior Member
 
Posts: 1
Joined: Tue Jun 28, 2011 2:20 pm

Re: Disabled field in custom admin generator field

Postby cordsally » Sat May 12, 2012 9:10 am

Its a good idea,iv.
Buy Quality Name Badges in lots of color:Name Badges
cordsally
Junior Member
 
Posts: 1
Joined: Sat May 12, 2012 9:07 am


Return to General discussion

Who is online

Users browsing this forum: No registered users and 6 guests