244863 Posted June 3, 2013 Share Posted June 3, 2013 Here is the code for my view: <div class="column span-24"> <div class="box"> <?php echo $this->html->tag('h2', $title_for_layout); echo $this->form->create('DocumentationDocument', array('action' => 'add', 'type' => 'file')); echo $this->form->inputs(array( 'File' => array( 'type' => 'file', 'label' => __('Local File', true), 'required' => true ), 'site_id' => array( 'type' => 'hidden' ), 'site_name' => array( 'class' => 'site_name span-8', 'type' => 'text', 'required' => true, 'between' => $this->html->tag( 'div', $this->html->para('notice', __('Begin typing the site name and choose from the resultant list.', true)), array('class' => 'field-description') ) ), 'documentation_category_id' => array( 'empty' => '...', 'class' => 'span-8', 'required' => true ), 'asset_category_id' => array( 'empty' => '...', 'class' => 'span-8', 'required' => true ), 'date_produced' => array('type' => 'date') )); echo $this->html->para('notice', sprintf("Maximum file size: $size_limit")); echo $this->element('standard-form-buttons'); ?> </div> </div> <?php echo $this->element('sites', array(), array('cache' => true)); echo $this->html->scriptBlock(' $(function() { $(".site_name").autocomplete(sites, { dataType: "json", matchContains: true, mustMatch: true, parse: function(data) { return $.map(data, function(row) { return { data: row, value: row.display_name, result: row.display_name } }); }, formatItem: function(item) { return item.display_name; }, formatResult: function(item) { return item.display_name; } }).result(function(event, data, formatted) { if (data && data.id) { allSites = $(".site", $("#sites")); index = allSites.index($(this).closest(".site")); $("#DocumentationDocumentSiteId").val(data.id); $(this).siblings(".error-message").hide(100).parent().removeClass("error"); } }); }); ', array('inline' => false)); $this->Form->unlockField('DocumentationDocument.site_id'); echo $this->form->end(); ?> If I remove the following line of JS the page posts fine: $("#DocumentationDocumentSiteId").val(data.id); I am pretty sure I have the unlockedField line correct as it works on other pages. Any ideas as to why it won't post? Thanks, Quote Link to comment https://forums.phpfreaks.com/topic/278714-cakephp-unlockedfields-error/ Share on other sites More sharing options...
244863 Posted June 3, 2013 Author Share Posted June 3, 2013 Hi, Tried this in my app controller's before filter: $this->Security->unlockFields = array('DocumentationDocument.site_id');still does not work, unless I uncomment that line of code??? Quote Link to comment https://forums.phpfreaks.com/topic/278714-cakephp-unlockedfields-error/#findComment-1433804 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.