Closed (won't fix)
Project:
Content Construction Kit (CCK)
Version:
7.x-2.x-dev
Component:
General
Priority:
Major
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
11 Oct 2011 at 04:18 UTC
Updated:
4 Apr 2012 at 16:42 UTC
I have created a drupal 7 module 'List (PHP)' that is sort of combination of List module and Computed Field. You use PHP to provide the values for the options. Additionally it passes in the values of other fields to allow for dynamic lists in combination with #ajax.
| Comment | File | Size | Author |
|---|---|---|---|
| list_php.zip | 4.01 KB | grom358 |
Comments
Comment #1
robcarr@grom358 - thanks for posting this.
This
*almost*works for me: I want to use PHP to grab allowed values for a content type text list from a specific node (so that the allowed values list is effectively editable by certain end users, rather than requiring intervention of a site builder). So have used the following code to generate my allowed values.Originally, I was generating an associative array (as commented out in above code) so I could use the PHP evaluation of the CCK module. However, this resulted in 'An illegal choice has been detected...' error and I could not save the node if any of the check boxes had been selected (it's set to unlimited values, so the node edit form presents check boxes).
So I've enabled the list_php module, set up a field within a content type and selected a few of the computed allowed values in a node. This time the node has been saved without error,
but has not recorded any of the selected check box values. However, I'm getting a Warning: array_fill() [function.array-fill]: Number of elements must be positive in list_php_options_list() (line 306 of /list_php/list_php.module). error on the content type field settings page, so I suspect I'm not using your contributed code correctly.Would welcome any advice, examples or even a tiny bit of guidanceEDIT: Tried the old 'turn it all off, then on again' approach (ie, deleted a field, cleared caches and created a new field): all works fine. Only minor snag is that I'm still seeing the array_fill() error
Comment #2
robcarrQuick fix that seems to stop the Warning: array_fill() [function.array-fill]: Number of elements must be positive in list_php_options_list() (line 306 of /list_php/list_php.module) error occurring by checking that $field['cardinality'] is positive:
Would roll patch but not sure anyone else is that interested...
Comment #3
yang_yi_cn commentedthis is great! can some one commit this or put it into a separate module?
Comment #4
karens commentedNo new features are going into CCK for D7. If someone wants something like this is will need to be a new project. And it sounds like it ought to be its own project anyway. There is a process for applying to create a new project, or you could start it out as a sandbox. I'm not sure what the process is, but Google around and you should be able to find it.