Jump to content

Recommended Posts

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,

Link to comment
https://forums.phpfreaks.com/topic/278714-cakephp-unlockedfields-error/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.