We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Channel Form - Change Author Dropdown Menu

How Do I?

IC360 (Oliver Cannell)'s avatar
IC360 (Oliver Cannell)
241 posts
about 9 years ago
IC360 (Oliver Cannell)'s avatar IC360 (Oliver Cannell)

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>
   {/exp:query}
  </select>
 {/exp:channel:form}
{/exp:channel:entries}

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

<option value=""></option>
       
Rob Allen's avatar
Rob Allen
2,950 posts
about 9 years ago
Rob Allen's avatar Rob Allen

Does your query work outside of the channel form tag?

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

       
IC360 (Oliver Cannell)'s avatar
IC360 (Oliver Cannell)
241 posts
8 years ago
IC360 (Oliver Cannell)'s avatar IC360 (Oliver Cannell)

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

       
Rob Allen's avatar
Rob Allen
2,950 posts
8 years ago
Rob Allen's avatar Rob Allen

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 😊

       
IC360 (Oliver Cannell)'s avatar
IC360 (Oliver Cannell)
241 posts
7 years ago
IC360 (Oliver Cannell)'s avatar IC360 (Oliver Cannell)

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>
  {/exp:user:users}
 </select>
{/exp:channel:form}
       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.