Hi everyone. I've got - propably very easy again - problem. I've generated scaffold, with columns such as article body, which will have lot of content, and it shouldn't be shown in scaffold (in fact in listing, in add, edit of course it should).Is it possible to set, which columns should be hidden?
The scaffold views retrieve the column names using getContentColumns() and loop through the results. If you want to hide some of the fields you will have to edit the view. ~
I was doing this little trick in RubyOnRials, i believe it works for your sitution, The Scaffolding loops over the columns name and evaluate each column for the available objects (e.g. $post.get('title') )
<?php $content_columns = array_keys($Post->getContentColumns()); ?>
This Gives you a string array of the columns names, including your 'body' column, what you have to do is removing 'body' string from this array.
In Rails, you can simply do the following, to exclude body, created_at, and updated_at columns:
<% columns = columns - ['body','created_at','updated_at'] %>
This maybe can't be done using PHP (i am not sure), anyways, you need to remove the unwanted column from the array, Or you can put a condition while looping, that if the current column equals to 'body' then skip the evaluating of the column.
I hope this helps.
I'm little bid confused, that it can't be done automatically, however, if someone wants:
listing.tpl:
find:
$content_columns = array_keys($Site->getContentColumns());
replace:
$content_columns = $Site->getContentColumns();
unset($content_columns['body']);
$content_columns = array_keys($content_columns);
and replace 'body' with desired column ;)
overwrite
...->getContentColumns();
in the model.
An example of Kaste's nice solution
function getContentColumns()
{
$columns = parent::getContentColumns();
unset($columns['lock_version']);
return $columns;
}
1 to 6 of 6