Not signed in (Sign In)
Welcome Guest!
Want to take part in these discussions? If you have an account, sign in now.
If you don't have an account, apply for one now.
    • CommentAuthorkkrzyzak
    • CommentTimeMar 6th 2008
     

    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?

    •  
      CommentAuthorriffed
    • CommentTimeMar 6th 2008
     

    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. ~

    • CommentAuthormkhatib
    • CommentTimeMar 6th 2008
     
    • 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.

    • CommentAuthorkkrzyzak
    • CommentTimeMar 6th 2008
     

    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 ;)

    • CommentAuthorKaste
    • CommentTimeMar 6th 2008
     

    overwrite

    ...->getContentColumns();
    

    in the model.

    • CommentAuthorpauld
    • CommentTimeMar 28th 2008
     

    An example of Kaste's nice solution

    function getContentColumns()
    {
        $columns = parent::getContentColumns();
        unset($columns['lock_version']);
        return $columns;
    }
    
Add your comments
    Username Password
  • Format comments as