Problems, need help? Have a tip or advice? Post it here.
14 posts Page 1 of 2
Hi,

Do I understand correctly that the use of a richtext field on the new DataBound Forms isn't possible ? Or must I load the ckeditor script on the frontend pages first.

Also: I 'm not sure how to use the mode='edit' in a workflow e.g.

When I have a form that creates a new page and after the user submits the form, he/she gets redirected to the new created page. On this point the user notice an error and want to correct this... can this only done by creating a update form or is there a way to edit the fields of the new page inline (directly)..

Thanks
I load frameworks and write bugs on top of them, after that I rearrange the code so that it looks like a cool product.
Hi,

Do I understand correctly that the use of a richtext field on the new DataBound Forms isn't possible ?
It is certainly possible. In fact, it is now possible to use on the front-end every single type of editable region we use in the admin-panel.

The only catch is that those regions that have no cms:input counterpart (e.g. richtext, nicedit, relation, repeatable etc.) depend on their specific CSS/JS and other assets to work correctly.
If we can manually add the required assets to the front-end template, we can use those without a problem.

Addressing specifically the richtext type, it'd require adding the following line in your template (just below the <?php require_once( 'couch/cms.php' ); ?> statement)
Code: Select all
<?php require_once( K_COUCH_DIR.'includes/ckeditor/ckeditor.php' ); ?>


Also: I 'm not sure how to use the mode='edit' in a workflow e.g.
The documentation for DataBound Forms http://www.couchcms.com/docs/concepts/d ... forms.html) discusses creating a custom edit screen in the admin-panel. The code for it (can be found in the attached zip) implements the 'edit' mode. You can study it to see how exactly it works. In short, it requires the 'id' of the page to edit.

When I have a form that creates a new page and after the user submits the form, he/she gets redirected to the new created page. On this point the user notice an error and want to correct this... can this only done by creating a update form or is there a way to edit the fields of the new page inline (directly)..
Once a page gets created, we'll have to use the 'edit' mode (discussed above) to make changes to it.

While this is perfectly possible to implement, there is a small practical issue that'd make it not feasible (for now at least).

See, what you are trying to code up is a mini admin-panel where the visitor edits his own page(s). To allow this to happen we'll need to associate pages with the users who created them (else you'll open up the possiblity for knowledgeable users to edit *all* pages).
Currently, as you know, we don't have a proper user/access-control system in place.
So, it'd be better not to implement 'edit' on the front-end for now.

Of course, releasing a proper user module is one of the top priorities now and we should have one shortly.
That coupled with the already existing 'relations' feature will finally open up the doors to create full-fledged applications like newsletters, forums etc. using Couch tags alone.

Hope this answers your queries.
Thanks.
Hi KK,

Thanks for the info. I missed the attached files totally ... i was to eager to get started with this.

As for the <?php require_once( K_COUCH_DIR.'includes/ckeditor/ckeditor.php' ); ?> tip I couldn't find that one.

See, what you are trying to code up is a mini admin-panel where the visitor edits his own page(s). To allow this to happen we'll need to associate pages with the users who created them (else you'll open up the possiblity for knowledgeable users to edit *all* pages).


Yes, something like that ... in this case there won't be many users for creating a page at the front-end we want to use this more as a mobile input form feature that can be shown and printed trough a browser as a report. So we have already those input pages excluded from a regular visitor ( by <cms:if k_user_access_level ge .. >). I suppose this way of using the 'edit' on the front-end is not really a problem...

Thanks again !
I load frameworks and write bugs on top of them, after that I rearrange the code so that it looks like a cool product.
This helped me KK.. But I'm unable to see the changes I made in template in front-end untill I login into admin panel. Y so?
Was this resolved Robert? If not, could you explain a bit more what happened?
I'm still not able to get the 'edit' mode to work (Admittedly, I'm a novice couch cms user). Could someone elaborate on the differences between create and edit mode?

Thanks,

Sam
@sam,

Suppose you have a template named 'some-template.php', when the following code is executed the form shows up with the input fields blank. This is because we are in the 'create' mode - a new page will get created with the inputted values once the form is successfully submitted.
Code: Select all
<cms:form 
    masterpage='some-template.php'
    mode='create'
    method='post'
    >
   
    ...
   
</cms:form>

As opposed to the example above, when the following code executes, the form shows up with the input fields already filled up with values picked from an existing page with id '112'. Any changes we make will be saved back to the same page upon successful submission of the form. This is the 'edit' mode.
Code: Select all
<cms:form 
    masterpage='some-template.php'
    mode='edit'
    page_id='112'
    method='post'
    >
   
    ...
   
</cms:form>

Of course, we are not likely to use the 'edit' mode with a fixed 'page_id'. It'd likely come from the URL querystring etc.
As mentioned in a previous reply of mine above, you can take a look at the sample code that comes with the documentation for one way how this could be implemented.

Hope this helps.
@KK , Thanks for the quick reply.

I get as far as the content for the field I am trying to edit shows up, but changes I make and submit don't seem to apply.

I tried doing a very basic template:
Code: Select all
<cms:template title='Post' clonable='1'>
<cms:editable name='tagline' label='Tagline' required='0' validator='max_len=140' type='text' />
</cms:template>


And the corresponding form for just one page (to test):
Code: Select all
<cms:form masterpage=k_template_name mode='edit' page_id='1' method='post'>
      <cms:input id="tagline" name="tagline" type="bound"/>
      <cms:input name="submit" type="submit" value="Send" />
</cms:form>


The page for id '1' display a text box with the value of 'tagline' I entered in the admin side. Submit appears to do something, but the desired field is never changed.

I tried playing with the tutorial code you provided but I've never been able to get it to work on the front end. Hopefully I'm missing something obvious.
@samnovak,
You are not using cms:db_persist_form to actually save the changes :)

Please try the following code (I've also added error reporting).
Code: Select all
<cms:form masterpage=k_template_name mode='edit' page_id='1' method='post'>
    <cms:if k_success >   
        <cms:db_persist_form />               
    </cms:if>
   
    <cms:if k_error >
        <cms:each k_error >
            <br><cms:show item />
        </cms:each>
    </cms:if>

      <cms:input id="tagline" name="tagline" type="bound"/>
      <cms:input name="submit" type="submit" value="Send" />
</cms:form>

Hope this helps. Do let us know.
@KK, Thank you!

This works perfectly when I assign a static value to 'page_id'.

I've been playing with different ways to dynamically assign 'page_id':
Code: Select all
<cms:form masterpage='index.php' mode='edit' page_id=<?php echo $pageid?> method='post'>

Where:
Code: Select all
$pageid = $_POST["pageid"];


At this point, all of the values associated with that specific page show up in the form. However, when I submit the form I get the error:

Code: Select all
ERROR: Tag "form" - page_id required


I think it has something to do with how php handles variable, but I can't seem to overcome this hurdle. I'd welcome any suggestions you have

Thanks again,

Sam
14 posts Page 1 of 2
cron