AuthorWilliam Beh

HomeArticles Posted by William Beh

Laravel remove &quot from json

When getting data in json

$users = User::all()->json();

In blade template using the data

var users = {{ $users }}

It will return error because the encoding will get code like &quot

Escaping the data with {{ }} automatically in Laravel 5. Use {!! $users !!} instead.

Continue Reading

Using Google Forms on WordPress Page

Google Forms provides a very simple way to create a form to collect and organise information. The form can be embedded into website. The submitted information can be viewed in the response spreadsheet.

If you want to customize the layout to suit your website, Google Forms customization is quite limited. We take a look on how to create the form on wordpress page. It works on other types of web pages too. This way you can directly use your website theme and submit the form into Google Forms. We will take a look at how to create the form on your website and how to customize the response page.

Firstly, create a Google Form or use an existing form. Learn more on how to create Google Form on the help page. I’ve created a sample form.

Screen Shot 2015-09-17 at 10.47.14 AM

View the page source for the form. Copy the whole section under the form tag. Sample input id entry.177001325

<form form action="https://docs.google.com/a/bwltech.com/forms/d/1dtlRUqvvcGTSopi88qVbvP9cCk_rixG-B68oB6HCPK8/formResponse" method="POST" id="ss-form" target="_self" onsubmit="">
.... 
<label class="ss-q-item-label" for="entry_177001325">Name</label>
<input type="text" name="entry.177001325" value="" class="ss-q-short" id="entry_177001325" dir="auto" aria-label="Name  " title="">
....
</form>

You can customized the form layout as needed to suit the website theme. You can use form design, eg Bootstrap. Validation can be added too, eg JQuery Validation.

Create a WordPress post or page. Paste the form HTML code into the page. The form is now available on your website. This works not only on WordPress but also almost any website. You can test submitting the form.

Submitting the form will create a response on the Google Forms’ response spreadsheet. You still get the Google Forms’ response page on submitting the form. So the second step is to create a response page on your website. I’ve create a Thank You page on WordPress.

To use the response page, add a hidden iframe on the form page.

<iframe name="hidden_iframe" id="hidden_iframe" style="display:none;" onload="if(submitted){window.location='/sample-google-form/google-form-thank-you-page';}">

Update the form tag, target=”hidden_iframe” onsubmit=”submitted=true;”

<form action="https://docs.google.com/a/bwltech.com/forms/d/1dtlRUqvvcGTSopi88qVbvP9cCk_rixG-B68oB6HCPK8/formResponse" method="POST" id="ss-form" target="hidden_iframe" onsubmit="submitted=true;" class="form-horizontal">

When submitting the form, you should get the customized response page. You can view the Google Forms sample here.

Continue Reading

OverAPI Collecting All Cheat Sheets

OverAPI have hundreads of cheat sheets on technologies from HTML, CSS, Regex, Ruby, etc.
overAPI

A simple search, I found Scala Cheat Sheet which provides links the contents. As of writing now, MongoDB is not available. I’m sure more will be added. It provide a full list A-Z of cheat sheets. Definitely a good bookmark for developers.

Continue Reading

WebSphere Portal Redeploy Web Module Application

For some unknown reason, the web module application was missing on WebSphere Portal 8. Thus we can’t deploy any new portlet applications. The Manage Web Modules, Manage Applications and Manage Portlets are missing. After spending some time with IBM PMR, the solution was to reinstall the application.

At <install_loc>/PortalServer/bin, run the command below

xmlaccess.bat -in <install_loc>/PortalServer\ap\wp.ap.portletmanager\config\templates\DeployPortlets_cfgfw.xml -url http://localhost:10039/wps/config -user username -password password

That solved the issue and we portlets are available. But the Web Module page still remain empty and can’t manually insert the portlets.

IBM PMR gave the Setup Manage Portlet XML file.

xmlaccess.bat -user wpsadmin -password wpsadmin -url http://localhost:10039/wps/config -in SetupManagePortlet.xml

The Web Module, Applications and Portlets pages are setup with the correct portlet again.

Web Experience Factory Advance Field Validation

Using View and Form builder, the input form by default have a simple validation if the field is empty.

I need to check if an input text field already exist in the database.

Let’s say I have a text field call USERID. I need to check if there’s a same USERID in the table before I can save the document. Create a SQL Call builder to select base on USERID, eg

select * from TABLE where USERID = ?

Use Data Field Settings builder for the validation. For the USERID field, use the RegularExpression(RegExString) as Validation Op.
DataFieldSettings
For the Argument, create an Action List builder that return the same USERID value if it is not found in the DB.

Example, I’ve create a Variable builder to store the error message to be display. Then I create the Action List builder. First check if the USERID is empty, if yes then return Empty error message. Then call the SQL and check if the result is 1 or more rows

DataFieldSettings2

The action list return false if the field empty or the USERID is found. If the USERID is NOT found, then it return the USERID itself which will make the regex validate same as the input.

Regex in LotusScript

After more than 10 years coding, I still learn something new on Lotus.

I need to do some checking on certain value, so regex came into mind. So far I haven’t actually used regex in LotusScript. A simple search give me result to use “Like” operator. It function similar with regex, and determines whether a string expression matches a pattern string.

I need to check if a value of a field contains only “0000”. The example syntax that can be used is as below

	Dim subject List As String

	subject(0) = "000000"
	subject(1) = "100000"
	subject(2) = "000001"
	subject(3) = "000300"
	subject(4) = "asdf"
	subject(5) = "ZASE"
	subject(6) = "Z00000"

	ForAll s In subject
		If (s Like "*[1-9a-zA-Z]*") Then
			' contains other than 0
		Else
			' contains only 0
		End If
	End ForAll
Continue Reading

Android 4.1 Jelly Bean on Nexus S

For Nexus S users, you can get the lastest and greatest Android version 4.1 Jelly bean at XDA. It’s a port from Google’s Jelly Bean SDK and most of the feature is working.

The feature I wanted to try out most is Google Now. From review found around the Internet, shows that the speech recognition is good. I’m having some issue here, maybe because of my Malaysian English. It’s quite a hit or miss. Don’t expect good location/direction results here in Malaysia as most places are not recognised. Setting alarm is quite accurate.

If you have a Nexus S, what are you waiting for. Go ahead and get the update.

Continue Reading