For this example I willbe updating the field 'interests' inside 'users'
table.
okay, on top of your view you should have
<script type="text/javascript" src="/js/jeditable.js"></script>
!!Dont forget to include the jquery file inside your layout view!!
after that, somwhere the input you want to update:
<span class="interests" id="<?php echo $user['User']['id']; ?>"><?php echo
$user['User']['interests']; ?></span>
on the bottom of your view:
<script type="text/javascript">
$(document).ready(function() {
$('.interests').editable('/users/edituserinfo/interests', {
id : 'data[User][id]',
type : 'textarea',
cancel : "<button type=\"cancel\" class=\"button-cancel\"><?php
__('Cancel'); ?></button>",
submit : '<button type="submit" class="button-ok">OK</button>',
indicator : '<img src="/img/ajax-loader.gif">',
name : 'data[User][interests]',
tooltip : "<?php __('Click to edit'); ?>",
rows : 3,
onblur : 'ignore',
cssclass : 'myacc-editable-userinfo'
});
});
</script>
and inside your controller a function:
function edituserinfo ($field) {
if ($this->data) {
App::import('Core', 'sanitize');
$edit_field = Sanitize::clean($this->data['User'][$field]);
$this->User->id = $this->data['User']['id'];
$this->User->query("UPDATE users SET $field = '$edit_field' WHERE id =
" . $this->User->id);
$this->_refreshAuth();
$this->set('result', $edit_field);
}
} //Here the $field and represents the field inside database, and
$edit_field is the value sent from the view, For this example I used inside
'users' table the field interests
2012/10/10 Chris <[email protected]>
> Ok Ivan,... I setup jeditable
>
> this is in a header:
> <?php echo $this->Html->script('jquery.jeditable'); ?>
>
> this is my view:
>
> <script type="text/javascript" charset="utf-8">
> $(function() {
> $(".edit").editable("/users/ajax_short_status/<?php echo
> $user_obj['User']['id'] ?>", {
> indicator : "Saving...",
> tooltip : "Move mouseover to edit...",
> event : "mouseover",
> name : "data['User']['short_status']",
> style : "inherit"
> });
> });
> </script>
>
> and this is my function:
>
>
> function ajax_short_status($id = null) {
> $this->authorize();
>
> if(!($user = $this->User->findById($id)))
> {
> die();
> }
> else
> {
> $this->authorize($user['User']['id']);
>
> $user['User']['short_status'] = $this->data['User']['short_status'];
>
> $this->User->save($user);
> echo $user['User']['short_status'];
> die();
> }
> }
>
> and it still not saving it... what am I doing wrong...???
> do you have an example please...?
>
> thanks
> chris
>
>
> On Tuesday, October 9, 2012 3:22:00 PM UTC-7, ivnrmc wrote:
>
>> Yes, that is the plugin.
>>
>> sent from my Samsung Galaxy S
>>
>> Ivan Rimac
>>
>> mail: [email protected]
>> mob: +385 95 555 9966
>>
>> Dana 10.10.2012. 00:16 "Chris" <[email protected]> je napisao/la:
>>
>> is this the url?
>>>
>>> http://www.appelsiini.net/**projects/jeditable<http://www.appelsiini.net/projects/jeditable>
>>>
>>>
>>> On Tuesday, October 9, 2012 2:32:04 PM UTC-7, ivnrmc wrote:
>>>>
>>>> I am using jEditable for this kind of things, i can send you piece of
>>>> code for this. For this, i think there is a problem with the script, you
>>>> should check is there form generated when you try to edit your short
>>>> status.
>>>>
>>>> sent from my Samsung Galaxy S
>>>>
>>>> Ivan Rimac
>>>> mail: [email protected]
>>>> mob: +385 95 555 9966
>>>> Dana 9.10.2012. 23:10 "Chris" <[email protected]> je napisao/la:
>>>>
>>>>> thanks Ivan for your time,...
>>>>> this is inplace editor action using jquery,... and this is what I have
>>>>> inside my view:
>>>>>
>>>>> where do I put form input,...?
>>>>>
>>>>> <p id="editme8" style="float: left; margin: 0 0 10px 10px;
>>>>> border: 1px solid #aaa; width: 735px; padding: 8px 5px 8px 5px; display:
>>>>> block; overflow: hidden;">
>>>>> <?php if(empty($user_obj['User']['**sh**ort_status'])): ?>
>>>>> <?php echo ucfirst(__('short status - Max: 200 characters', true)) ?>:
>>>>> <?php else: ?>
>>>>> <?php echo $user_obj['User']['short_**statu**s'] ?>
>>>>> <?php endif ?>
>>>>> </p>
>>>>>
>>>>>
>>>>> <?php if($user->is_authorized($user_****obj['User']['id'])): ?>
>>>>> <script>
>>>>> $(document).ready(function(){
>>>>> $("#editme8").editInPlace({
>>>>> callback: function(unused, enteredText) { return enteredText; },
>>>>> url: "/users/ajax_short_status/<?**ph**p echo $user_obj['User']['id']
>>>>> ?>",
>>>>> bg_over: "#cff",
>>>>> field_type: "textarea",
>>>>> textarea_rows: "15",
>>>>> textarea_cols: "35",
>>>>> saving_image: "./images/ajax-loader.gif"
>>>>> });
>>>>> });
>>>>> </script>
>>>>> <?php endif ?>
>>>>>
>>>>>
>>>>> On Tuesday, October 9, 2012 1:17:59 PM UTC-7, ivnrmc wrote:
>>>>>>
>>>>>> inside your view you need to havesomething like this:
>>>>>>
>>>>>> <?php
>>>>>>
>>>>>> echo $this->Form->create('User');
>>>>>> echo $this->Form->input('User.**short****_status');
>>>>>> echo $this->Form->end();
>>>>>>
>>>>>> ?>
>>>>>>
>>>>>> and then inside your controller action:
>>>>>> $user['User']['short_status'] = $this->data['User']['short_**sta****
>>>>>> tus'];
>>>>>>
>>>>>> also before save, you need to specify what user exactly are you
>>>>>> saving, something like this:
>>>>>>
>>>>>> $this->User->id = $this->Auth->user('id');
>>>>>>
>>>>>>
>>>>>> 2012/10/9 Chris <[email protected]>
>>>>>>
>>>>>>> hi Ivan,...
>>>>>>>
>>>>>>> it didn't work,... I even tried
>>>>>>> $user['User']['short_status'] = $this->data['User']['short_**sta****
>>>>>>> tus'];
>>>>>>>
>>>>>>> no luck,...
>>>>>>>
>>>>>>>
>>>>>>> On Tuesday, October 9, 2012 12:22:57 PM UTC-7, ivnrmc wrote:
>>>>>>>
>>>>>>>> $user['User']['short_status'] = $this->data['User']['value'];
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> 2012/10/9 Chris <[email protected]>
>>>>>>>>
>>>>>>>>> hi guys,... I'm in cake 1.3,... please help,...
>>>>>>>>> I can't read form value from inplace editor in a controller,...
>>>>>>>>> any other approch,...?
>>>>>>>>>
>>>>>>>>> $user['User']['short_status'] = $this->params['form']['value']
>>>>>>>>> ********;
>>>>>>>>>
>>>>>>>>> $this->User->save($user);
>>>>>>>>> echo $user['User']['short_status'];
>>>>>>>>> die();
>>>>>>>>>
>>>>>>>>> thanks in advance
>>>>>>>>>
>>>>>>>>> --
>>>>>>>>> Like Us on FaceBook
>>>>>>>>> https://www.facebook.com/**CakeP******HP<https://www.facebook.com/CakePHP>
>>>>>>>>> Find us on Twitter http://twitter.com/CakePHP
>>>>>>>>>
>>>>>>>>> ---
>>>>>>>>> You received this message because you are subscribed to the Google
>>>>>>>>> Groups "CakePHP" group.
>>>>>>>>> To post to this group, send email to [email protected].
>>>>>>>>> To unsubscribe from this group, send email to cake-php+u...@**
>>>>>>>>> googlegroups.com******.
>>>>>>>>>
>>>>>>>>> Visit this group at http://groups.google.com/**group******
>>>>>>>>> /cake-php?hl=en <http://groups.google.com/group/cake-php?hl=en>.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>> *Ivan Rimac***
>>>>>>>> mail: [email protected]
>>>>>>>> *tel: +385 95 555 99 66*
>>>>>>>> *http://ivanrimac.com*
>>>>>>>>
>>>>>>>> --
>>>>>>> Like Us on FaceBook
>>>>>>> https://www.facebook.com/**CakeP****HP<https://www.facebook.com/CakePHP>
>>>>>>> Find us on Twitter http://twitter.com/CakePHP
>>>>>>>
>>>>>>> ---
>>>>>>> You received this message because you are subscribed to the Google
>>>>>>> Groups "CakePHP" group.
>>>>>>> To post to this group, send email to [email protected].
>>>>>>> To unsubscribe from this group, send email to cake-php+u...@**
>>>>>>> googlegroups.com****.
>>>>>>> Visit this group at http://groups.google.com/**group****
>>>>>>> /cake-php?hl=en <http://groups.google.com/group/cake-php?hl=en>.
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> *Ivan Rimac***
>>>>>> mail: [email protected]
>>>>>> *tel: +385 95 555 99 66*
>>>>>> *http://ivanrimac.com*
>>>>>>
>>>>>> --
>>>>> Like Us on FaceBook
>>>>> https://www.facebook.com/**CakeP**HP<https://www.facebook.com/CakePHP>
>>>>> Find us on Twitter http://twitter.com/CakePHP
>>>>>
>>>>> ---
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "CakePHP" group.
>>>>> To post to this group, send email to [email protected].
>>>>> To unsubscribe from this group, send email to cake-php+u...@**
>>>>> googlegroups.com**.
>>>>> Visit this group at
>>>>> http://groups.google.com/**group**/cake-php?hl=en<http://groups.google.com/group/cake-php?hl=en>
>>>>> .
>>>>>
>>>>>
>>>>>
>>>> --
>>> Like Us on FaceBook
>>> https://www.facebook.com/**CakePHP<https://www.facebook.com/CakePHP>
>>> Find us on Twitter http://twitter.com/CakePHP
>>>
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "CakePHP" group.
>>> To post to this group, send email to [email protected].
>>> To unsubscribe from this group, send email to cake-php+u...@**
>>> googlegroups.com.
>>> Visit this group at
>>> http://groups.google.com/**group/cake-php?hl=en<http://groups.google.com/group/cake-php?hl=en>
>>> .
>>>
>>>
>>>
>> --
> Like Us on FaceBook https://www.facebook.com/CakePHP
> Find us on Twitter http://twitter.com/CakePHP
>
> ---
> You received this message because you are subscribed to the Google Groups
> "CakePHP" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> Visit this group at http://groups.google.com/group/cake-php?hl=en.
>
>
>
--
*Ivan Rimac***
mail: [email protected]
*tel: +385 95 555 99 66*
*http://ivanrimac.com*
--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
Visit this group at http://groups.google.com/group/cake-php?hl=en.