?
hi all,
I have set up a form to allow for adding & editing news items using the submit article action.
my setup:
preview tab:
text box - title
text area - introtext
text area - fulltext
hidden field - id
submit button
events tab:
on load:
Custom Code - page head (pathway adjustment, componentheading, h3 header)
db record loader - DB Field (id), Table (jos_content), Request Param (token)
show html
on submit:
Submit Article - Article Title Field (title), Full Text Field (fulltext), Intro Text Field (introtext), Author Alias Field (created_by_alias), Published:yes, category: news, section: news
Custom Code - message
prob 1)
I am running into a prob when trying to edit an existing item - a new content item is being created instead.
when looking at the action I noticed that neither field modified nor modified_by are being mentioned
I suppose something like
needs to be added somewhere.
prob 2)
also my users should be able to include images into articles as is possible when using the default means for adding content items. the textarea for introtext should be a regular textarea, that for fulltext an editor area. I think that would require an additional config param in the text area element (no / yes options) plus something like
could you please advice ?
J!1.5.23, CF4 RC 2.0
I have set up a form to allow for adding & editing news items using the submit article action.
my setup:
preview tab:
text box - title
text area - introtext
text area - fulltext
hidden field - id
submit button
events tab:
on load:
Custom Code - page head (pathway adjustment, componentheading, h3 header)
db record loader - DB Field (id), Table (jos_content), Request Param (token)
show html
on submit:
Submit Article - Article Title Field (title), Full Text Field (fulltext), Intro Text Field (introtext), Author Alias Field (created_by_alias), Published:yes, category: news, section: news
Custom Code - message
prob 1)
I am running into a prob when trying to edit an existing item - a new content item is being created instead.
when looking at the action I noticed that neither field modified nor modified_by are being mentioned
I suppose something like
$isNew = ($form->data['id'] < 1);
if ($isNew) {
$form->data['created'] = date("Y-m-d H:i:s");
$form->data['created_by'] = $user->id;
} else {
$form->data['modified'] = date("Y-m-d H:i:s");
$form->data['modified_by'] = $user->id;
}
needs to be added somewhere.
prob 2)
also my users should be able to include images into articles as is possible when using the default means for adding content items. the textarea for introtext should be a regular textarea, that for fulltext an editor area. I think that would require an additional config param in the text area element (no / yes options) plus something like
if ($element_params['enable_editor'] = 1) {
$editor =& JFactory::getEditor();
echo $editor->display($field, $value, $width, $height, $cols, $rows);
}
could you please advice ?
J!1.5.23, CF4 RC 2.0
Hi gabrielaH,
I haven't worked with the new Submit Artilce action yet so these ansers are untested :-(
Usually double entries come because the id value isn't present. You may need to add a hidden input to ths form to carry that through.
You can set the dates with a Custom Code action before the Sumit Article action. Only set the created date if this is a new article, otherwise leave the existing value.
I just don't know about the Rich Text Editor, sorry.
Bob
I haven't worked with the new Submit Artilce action yet so these ansers are untested :-(
Usually double entries come because the id value isn't present. You may need to add a hidden input to ths form to carry that through.
You can set the dates with a Custom Code action before the Sumit Article action. Only set the created date if this is a new article, otherwise leave the existing value.
I just don't know about the Rich Text Editor, sorry.
Bob
?
Hi Bob,
thanks for getting back to me!
I have a hidden input for the id field (pls see the very top of my initial post)
isn't it rather because the id is set up as
in submit_article.php ?
I am confused with that I'm afraid.
you are suggesting entering it in a custom code action before the submit_article action? from my understanding the submit_article action would override this again wouldn't it? at least partially
the submit_article action says:
and:
without any conditions around it.
thanks for getting back to me!
Usually double entries come because the id value isn't present. You may need to add a hidden input to ths form to carry that through.
I have a hidden input for the id field (pls see the very top of my initial post)
isn't it rather because the id is set up as
$form->data['id'] = null;
in submit_article.php ?
You can set the dates with a Custom Code action before the Sumit Article action. Only set the created date if this is a new article, otherwise leave the existing value.
I am confused with that I'm afraid.
you are suggesting entering it in a custom code action before the submit_article action? from my understanding the submit_article action would override this again wouldn't it? at least partially
the submit_article action says:
$form->data['created_by'] = $user->id;
$form->data['created'] = date("Y-m-d H:i:s");
and:
$form->data['id'] = null;
without any conditions around it.
?
I think I found the solution for the submit_article action:
find in ../administrator/components/com_chronoforms/form_actions/submit_article/submit_article.php:
and adjust for:
also find:
and adjust for:
this also fixes the title alias which has not been created before
find in ../administrator/components/com_chronoforms/form_actions/submit_article/submit_article.php:
$form->data['created_by'] = $user->id;
$form->data['created'] = date("Y-m-d H:i:s");
and adjust for:
$isNew = ($form->data['id'] < 1);
if ($isNew) {
$form->data['id'] = null;
$form->data['created_by'] = $user->id;
$form->data['created'] = date("Y-m-d H:i:s");
if (!$form->data['publish_up']) $form->data['publish_up'] = $form->data['created'];
} else {
$form->data['id'] = (int)$form->data['id'];
$form->data['modified_by'] = $user->id;
$form->data['modified'] = date("Y-m-d H:i:s");
}
also find:
$form->data['id'] = null;
$form->data['alias'] = null;
and adjust for:
$form->data['alias'] = JFilterOutput::stringURLSafe($form->data['title']);
this also fixes the title alias which has not been created before
Hi GabrielaH,
Well done, thank you.
Small question . . . if it's a new article should the modified date be set the same as the created by date?
Bob
Well done, thank you.
Small question . . . if it's a new article should the modified date be set the same as the created by date?
Bob
?
well no I don't think so. it should rather remain untouched, i.e. keep the default value (0000-00-00 00:00:00) like with default content submission
?
something to add as I continue creating forms:
for making it work when adding static/dynamic select lists for categories / sections or radiobuttons for state field to preview tab find:
and adjust for:
and for being able to disable selection of state value in submit article action find in submit_article.ctp:
and adjust for:
the attached file holds all fixes outlined above
for making it work when adding static/dynamic select lists for categories / sections or radiobuttons for state field to preview tab find:
$form->data['catid'] = $params->get('catid', '');
$form->data['sectionid'] = $params->get('sectionid', '');
$form->data['state'] = $params->get('state', 0);
and adjust for:
if (!$form->data['catid']) $form->data['catid'] = $params->get('catid', '');
if (!$form->data['sectionid']) $form->data['sectionid'] = $params->get('sectionid', '');
if (!$form->data['state']) $form->data['state'] = $params->get('state', 0);
and for being able to disable selection of state value in submit article action find in submit_article.ctp:
<?php echo $HtmlHelper->input('action_submit_article_{n}_state_config', array('type' => 'select', 'label' => 'Published ?', 'options' => array(0 => 'No', 1 => 'Yes'), 'smalldesc' => 'If enabled it will set the article status to published.')); ?>
and adjust for:
<?php echo $HtmlHelper->input('action_submit_article_{n}_state_config', array('type' => 'select', 'label' => 'Published ?', 'options' => array('' => '-', 0 => 'No', 1 => 'Yes'), 'smalldesc' => 'If enabled it will set the article status to published.')); ?>
the attached file holds all fixes outlined above
Hi Gabriela,
The submit article action does a simple article insertion, it makes sure that the id=null so that the frontend user can't use the form to edit existing articles, so, I believe that if you need to edit existing articles or add more selections like category or so then you can simply use a "DB Save" action instead, this should give you the flexibility you need.
Regards,
Max
The submit article action does a simple article insertion, it makes sure that the id=null so that the frontend user can't use the form to edit existing articles, so, I believe that if you need to edit existing articles or add more selections like category or so then you can simply use a "DB Save" action instead, this should give you the flexibility you need.
Regards,
Max
This topic is locked and no more replies can be posted.