Valid CCK drupal fields

Basically, I want to just print every valid value in the CCK field.

I know that valid values ​​are stored inside a text field in a table: 'content_node_field'.

values ​​are then stored within 'global_settings'

I want to somehow print each valid value using a PHP loop.

however, all values ​​are stored in one text field. It is difficult for them to print each value separately.

+3
source share
2 answers

Something like this should do the trick.

// Get the global_settings like you described.
$serialized_data = db_result(db_query("..."));
// Unserialize the data.
$unserialized_data = unserialize($serialized_data)
// Foreach the allowed values.
$values = array();
foreach(explode("\n", $unserialized_data['allowed_values']) as $value) {
  $values[] = $value;
}
+1
source

, PHP, [] , :

<input type="text" name="myname[]" />

:

foreach($myname as $value)
{
  echo $value . '<br />';
}

:

json_decode, :

:

$json = '{"a":1,"b":2,"c":3,"d":4,"e":5}';

var_dump(json_decode($json, true));
0

Source: https://habr.com/ru/post/1741906/


All Articles