Channel Form - Change Author Dropdown Menu

June 03, 2016 10:46am

Subscribe [2]
  • #1 / Jun 03, 2016 10:46am

    I’m trying to include a dropdown menu for changing an Entry’s Author, using Channel Form. EE 3.3.2

    {exp:channel:entries channel="properties" url_title="{segment_3}"}
     {exp:channel:form channel="{channel_short_name}" entry_id="{entry_id}"}
      <select name="author_id">
       {exp:query sql="SELECT member_id m_id, screen_name s_name FROM exp_members WHERE group_id = 1 OR group_id = 6 OR group_id = 7 ORDER BY screen_name ASC;"}
        <option value="{m_id}" {if "{m_id}" == "{author_id}"}selected="selected"{/if}>{s_name}</option>

    But the Select dropdown contains no data (even though there are the correct number of [empty] Options output).

    <option value=""></option>
  • #2 / Jun 10, 2016 6:52pm

    Rob (bluedreamer)'s avatar

    Rob (bluedreamer)

    2802 posts

    Does your query work outside of the channel form tag?

    If it does try pulling in the <options> via an embed…

  • #3 / Jun 20, 2016 5:48am

    Yes that seems to work…. But should we be able to access anything, from anywhere, using a SQL Query?

  • #4 / Jun 20, 2016 8:35am

    Rob (bluedreamer)'s avatar

    Rob (bluedreamer)

    2802 posts

    Channel form seems to be limited with what data you can show directly inside the form tag, I suspect because it’s only made to show actual fields that belong to the channel and relies on the currently logged in person as the author. That’s why pulling additional data in via an embed works 😊

  • #5 / Mar 14, 2018 1:54pm

    I’m doing a similar thing on another project and I’ve just managed to get this to work by using the EE Harbor User add-on.

    {exp:channel:form channel="properties"}
     <select name="author_id" id="author_id">
      {exp:user:users group_id="7" orderby="screen_name" sort="asc"}
       <option value="{member_id}">{screen_name}</option>
.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases