How to Change Author and Status
Posted: 09 April 2008 09:58 AM   [ Ignore ]
Member
RankRankRank
Total Posts:  98
Joined  2008-03-04

I would like to know the appropriate syntax for changing the author to an entry and how to change the status when editing a form using Form Helper.

For example.

A weblog entry is made by John Wayne and the moderator would like to change Author to anyone from a list of five:

Groucho Marx
Harry Potter
Ringo Starr
Bob the Builder
You Nameit

The other one is status. The default status is open. I would like to be able change it to anything:

Open
Approved
Pending
Etc.

Thanks in advance.

Forrest

Profile
 
 
Posted: 09 April 2008 10:07 AM   [ Ignore ]   [ # 1 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  2261
Joined  2006-10-18

Forrest,

To do status as a radio option:

{exp:form_helper:statuses entry_id="{entry_id}" exclude="open|closed|hamsandwich"}
<input type="radio" name="status" value="{entry_status}" {checked} /> {entry_status}
{
/exp:form_helper:statuses}

Status as a dropmenu:

<select name="status">
{exp:form_helper:statuses entry_id="{entry_id}" exclude="open|closed|hamsandwich"}
<option value='{entry_status}' {checked}>{entry_status}</option>
{/exp:form_helper:statuses}
</select>

As for Authors, you’re on your own on this one. You can change Authors if you’re an Administrator, but if you’re any other member group, it will return an error.

Code for Authors though… you’ll need to hardcode it as well.

<select name="author_id">
<
option value="1" {if author_id="1"} selected="selected"{/if}>Joe Shmo</option>
<
option value="2" {if author_id="2"} selected="selected"{/if}>Peter Piper</option>
<
option value="6" {if author_id="6"} selected="selected"{/if}>Jane Smith</option>
<
option value="22" {if author_id="22"} selected="selected"{/if}>Pie Man</option>
</
select>

 Signature 
Profile
 
 
Posted: 09 April 2008 10:09 AM   [ Ignore ]   [ # 2 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  2261
Joined  2006-10-18

You should really take a look into the documentation of the Plugin. You can view it here:

CP Home › Admin › Utilities › Plugin Manager › Form Helper

It really does explain all options, as well as examples smile

 Signature 
Profile
 
 
Posted: 09 April 2008 10:09 AM   [ Ignore ]   [ # 3 ]
Member
RankRankRank
Total Posts:  98
Joined  2008-03-04

Hardcoding is not a problem as there will be a limited number of them. So this will work fine.

Thanks again.

Profile
 
 
Posted: 09 April 2008 11:24 AM   [ Ignore ]   [ # 4 ]
Member
RankRankRank
Total Posts:  98
Joined  2008-03-04

Pie Man,

I have read the docs, but I still have questions, when it comes to application. For example the one about swapping out the author, which by the way is giving me an error.

When I put in the following code:

<select name="author_id">
<
option value="1" {if author_id="1"} selected="selected"{/if}>Forrest Anderson</option>
<
option value="2" {if author_id="2"} selected="selected"{/if}>New User</option>
<
option value="4" {if author_id="4"} selected="selected"{/if}>Bob the Builder</option>
</
select>

I get an error back:

Parse error: syntax error, unexpected ‘=’ in .../core/core.functions.php(637) : eval()’d code on line 120

I don’t see any rogue = signs in that code but I got the error when it was in and didn’t when I took it out.

Thanks.

Profile
 
 
Posted: 09 April 2008 11:58 AM   [ Ignore ]   [ # 5 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  2261
Joined  2006-10-18

Sorry Forrest,

It should have been:

<select name="author_id">
<
option value="1" {if author_id == "1"} selected="selected"{/if}>Forrest Anderson</option>
<
option value="2" {if author_id == "2"} selected="selected"{/if}>New User</option>
<
option value="4" {if author_id == "4"} selected="selected"{/if}>Bob the Builder</option>
</
select>

 Signature 
Profile
 
 
Posted: 09 April 2008 12:03 PM   [ Ignore ]   [ # 6 ]
Member
RankRankRank
Total Posts:  98
Joined  2008-03-04

No problems. Amazing how much trouble one little character can cause. Problem solved and I am almost there. Thanks for all your help.

Forrest

Profile