CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • New feature: easily embed an existing form
Pages: [1]

Author Topic: New feature: easily embed an existing form  (Read 697 times)

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
New feature: easily embed an existing form
March 29, 2012, 01:10:20 am
Hi,

Another one I'd like feedback on:

Beside the edit in place (for each field) http://forum.civicrm.org/index.php/topic,24049.0.html we needed to use the existing admin forms.

The reasoning was that if we were to expose all the options as edit in place, it would become a very busy interface, killing all benefits of the edit in place. So we aim at having the 80% that is likely to change exposed on the edit in place, and provide a link to access the usual and 100% complete form for the advanced options.

so on a normal link to the admin form (in this case for a field in a profile) <a href="/civicrm/admin/uf/group/field/update?reset=1&action=update&id=11">edit</a>

you simply apply the plugin $().crmEditable

Code: [Select]
<a class='crm-editable' href="/civicrm/admin/uf/group/field/update?reset=1&action=update&id=11">edit</a>

<script>
cj(function($){
$('.crm-editable').crmEditable ();
});
</script>

This does the following:

  • when you click on the link it ajax $().load the form adding a snippet param (so it does only only load the form & not the layout of the site)
  • it displays it under the link (inline)
  • it ajaxForm() it, meaning that you won't leave the page when you submit the form
  • if when you submit the form it was an error, it displays the form with the error message (normal behaviour)
  • if when you submit the form it saves it without error, it closes the form and call (optional) a 'success' function you can give as a param

The javascript code is in js/jquery/jquery.crmeditable.js (on trunk.profile in svn) the relevant code is the crmForm part

@ kurund/lobo

Is this possible to make CRM_Core_Form (or any generic place) aware that it is called by ajax instead of a "normal" call and so instead of on success returning the normal next screen (in case of editing a profile field, it's the page with the list of all the fields) it would return just the data it sends to postProcess (or the post) hooks?

so /civicrm/admin/uf/group/field/update?reset=1&action=update&id=11&snippet=6
on submit that is a success would return all the  $form->getVar(); ?

It isn't anything blocking, just to avoid unused calculations (we don't display the result on successful submit) and makes it a bit faster.

And having a json of what the server did would allow to do smarter things (eg avoid to refresh some part of the containing page because it knows what has been modified...)

X+



« Last Edit: March 29, 2012, 02:07:50 am by xavier »
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • New feature: easily embed an existing form

This forum was archived on 2017-11-26.